上一篇讲到DAO的配置,里面涉及到一些基本类,如下:
OSCacheProvider.java
public class OSCacheProvider implements CacheProvider { /** * The <tt>OSCache</tt> refresh period property suffix. */ public static final String OSCACHE_REFRESH_PERIOD = "refresh.period"; /** * The <tt>OSCache</tt> CRON expression property suffix. */ public static final String OSCACHE_CRON = "cron"; private static final Properties OSCACHE_PROPERTIES = new Config().getProperties(); /** * Builds a new {@link Cache} instance, and gets it's properties from the OSCache {@link Config} * which reads the properties file (<code>oscache.properties</code>) from the classpath. * If the file cannot be found or loaded, an the defaults are used. * * @param region * @param properties * @return * @throws CacheException */ public Cache buildCache(String region, Properties properties) throws CacheException { int refreshPeriod = PropertiesHelper.getInt( StringHelper.qualify(region, OSCACHE_REFRESH_PERIOD), OSCACHE_PROPERTIES, CacheEntry.INDEFINITE_EXPIRY ); String cron = OSCACHE_PROPERTIES.getProperty( StringHelper.qualify(region, OSCACHE_CRON) ); // construct the cache return new OSCache(refreshPeriod, cron, region); } public long nextTimestamp() { return Timestamper.next(); } public boolean isMinimalPutsEnabledByDefault() { return false; } /** * Callback to perform any necessary cleanup of the underlying cache implementation * during SessionFactory.close(). */ public void stop() { } /** * Callback to perform any necessary initialization of the underlying cache implementation * during SessionFactory construction. * * @param properties current configuration settings. */ public void start(Properties properties) throws CacheException { } }
BaseDAO.java
public class BaseDAO extends AbstractDaoSupport implements DAO { protected final Log log = LogFactory.getLog(getClass()); /** * @see com.timeson.framework.dao.DAO#saveObject(Object) */ public void saveObject(Object o) { getHibernateTemplate().saveOrUpdate(o); } /** * @see com.timeson.framework.dao.DAO#getObject(Class, java.io.Serializable) */ public Object getObject(Class clazz, Serializable id) { Object o = getHibernateTemplate().get(clazz, id); if(o == null) { throw new ObjectRetrievalFailureException(clazz, id); } return o; } /** * @see com.timeson.framework.dao.DAO#getObjects(Class) */ public List getObjects(Class clazz) { return getHibernateTemplate().loadAll(clazz); } /** * @see com.timeson.framework.dao.DAO#removeObject(Class, java.io.Serializable) */ public void removeObject(Class clazz, Serializable id) { getHibernateTemplate().delete(getObject(clazz, id)); } }
DAO.java
public interface DAO { /** * Generic method used to get all objects of a particular type. This * is the same as lookup up all rows in a table. * * @param clazz the type of objects (a.k.a. while table) to get data from * @return List of populated objects */ public List getObjects(Class clazz); /** * Generic method to get an object based on class and identifier. An * ObjectRetrievalFailureException Runtime Exception is thrown if * nothing is found. * * @param clazz model class to lookup * @param id the identifier (primary key) of the class * @return a populated object * @see com.springframework.orm.ObjectRetrievalFailureException */ public Object getObject(Class clazz, Serializable id); /** * Generic method to save an object - handles both update and insert. * * @param o the object to save */ public void saveObject(Object o); /** * Generic method to delete an object based on class and id * * @param clazz model class to lookup * @param id the identifier (primary key) of the class */ public void removeObject(Class clazz, Serializable id); }
spring
applicationContext-service.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="txProxyTemplate" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager" ref="transactionManager"/> <property name="transactionAttributes"> <props> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="Send*">PROPAGATION_REQUIRED</prop> <prop key="Complete*">PROPAGATION_REQUIRED</prop> <prop key="complete*">PROPAGATION_REQUIRED</prop> <prop key="Finish*">PROPAGATION_REQUIRED</prop> <prop key="finish*">PROPAGATION_REQUIRED</prop> <prop key="Require*">PROPAGATION_REQUIRED</prop> <prop key="send*">PROPAGATION_REQUIRED</prop> <prop key="remove*">PROPAGATION_REQUIRED</prop> <prop key="delete*">PROPAGATION_REQUIRED</prop> <prop key="add*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> <prop key="*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <!-- Generic manager that can be used to do basic CRUD operations on any objects --> <bean id="manager" parent="txProxyTemplate"> <property name="target"> <bean class="BaseManager"> <property name="DAO" ref="dao"/> </bean> </property> </bean> </beans>
涉及到的类
BaseManager.java
public class BaseManager implements Manager { protected final Log log = LogFactory.getLog(getClass()); protected DAO dao = null; /** * @see com.timeson.framework.service.Manager#setDAO(com.timeson.framework.dao.DAO) */ public void setDAO(DAO dao) { this.dao = dao; } /** * @see com.timeson.framework.service.Manager#getObject(java.lang.Class, java.io.Serializable) */ public Object getObject(Class clazz, Serializable id) { return dao.getObject(clazz, id); } /** * @see com.timeson.framework.service.Manager#getObjects(java.lang.Class) */ public List getObjects(Class clazz) { return dao.getObjects(clazz); } /** * @see com.timeson.framework.service.Manager#removeObject(java.lang.Class, java.io.Serializable) */ public void removeObject(Class clazz, Serializable id) { dao.removeObject(clazz, id); } /** * @see com.timeson.framework.service.Manager#saveObject(java.lang.Object) */ public void saveObject(Object o) { dao.saveObject(o); } }
Manager.java
public interface Manager { /** * Expose the setDAO method for testing purposes * * @param dao */ public void setDAO(DAO dao); /** * Generic method used to get a all objects of a particular type. * * @param clazz the type of objects * @return List of populated objects */ public List getObjects(Class clazz); /** * Generic method to get an object based on class and identifier. * * @param clazz model class to lookup * @param id the identifier (primary key) of the class * @return a populated object * @see com.springframework.orm.ObjectRetrievalFailureException */ public Object getObject(Class clazz, Serializable id); /** * Generic method to save an object. * * @param o the object to save */ public void saveObject(Object o); /** * Generic method to delete an object based on class and id * * @param clazz model class to lookup * @param id the identifier of the class */ public void removeObject(Class clazz, Serializable id); }
struts
<struts-config.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd"> <struts-config> <!--uncommnet this node if neccessary--> <global-forwards> <forward name="systemfailure" path="/WEB-INF/jsp/common/errors.jsp" contextRelative="true"/> <forward name="failure" path="/WEB-INF/jsp/common/errors.jsp" contextRelative="true"/> <forward name="userfailure" path="/indexTbMainInfopublish.do?method=getInfoTypeListindex" contextRelative="true"/> <forward name="sessionfailure" path="/WEB-INF/jsp/common/SessionError.jsp" contextRelative="true"/> <forward name="accessfailure" path="/WEB-INF/jsp/common/privilegeErrors.jsp" contextRelative="true"/> </global-forwards> <controller nocache="true" inputForward="true" maxFileSize="2M"/> <!-- ========== Messages Location =================================== --> <message-resources factory="com.timeson.framework.util.MultiMessageResourcesFactory" parameter="ApplicationResources" /> <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> <set-property property="pathnames" value="/WEB-INF/config/validator/validator-rules.xml"/> </plug-in> </struts-config>
struts-config-oa-sso.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd"> <struts-config> <form-beans> <form-bean name="ssoSinulateForm" type="org.apache.struts.action.DynaActionForm"> <form-property name="userID" type="java.lang.String"/> </form-bean> <form-bean name="ssoLoginForm" type="org.apache.struts.action.DynaActionForm"> <form-property name="userID" type="java.lang.String"/> <form-property name="userName" type="java.lang.String"/> <form-property name="password" type="java.lang.String"/> <form-property name="orgId" type="java.lang.String"/> <form-property name="company" type="java.lang.String"/> <form-property name="companyId" type="java.lang.String"/> <form-property name="temUserName" type="java.lang.String"/> <form-property name="temUserId" type="java.lang.String"/> <form-property name="codeStr" type="java.lang.String"/> </form-bean> <form-bean name="awokeSwitchForm" type="org.apache.struts.action.DynaActionForm"> <form-property name="awokeSwitchBean" type="com.timeson.oa.sso.model.SysAwokeSwitch"/> <form-property name="userName" type="java.lang.String"/> </form-bean> <form-bean name="TbMenuForm" type="org.apache.struts.validator.DynaValidatorForm"> <form-property name="idArr" type="java.lang.String[]"/> <form-property name="id" type="java.lang.String"/> <form-property name="menuId" type="java.lang.String"/> <form-property name="menuPid" type="java.lang.String"/> <form-property name="menuName" type="java.lang.String"/> <form-property name="menuUrl" type="java.lang.String"/> <form-property name="menuTitle" type="java.lang.String"/> <form-property name="menuTarget" type="java.lang.String"/> <form-property name="menuIcon" type="java.lang.String"/> <form-property name="menuIconopen" type="java.lang.String"/> <form-property name="menuOpen" type="java.lang.String"/> <form-property name="roleId" type="java.lang.Integer"/> </form-bean> </form-beans> <action-mappings> <action path="/redirectToSSO" parameter="/WEB-INF/jsp/sso/ssoEntry.jsp" type="org.apache.struts.actions.ForwardAction"/> <action path="/loginMailSys" name="ssoSinulateForm" parameter="method" scope="request" type="com.timeson.oa.sso.web.SsoAction"> <forward name="ssoForWard" path="/WEB-INF/jsp/sso/ssoForward.jsp"/> <forward name="failure" path="/WEB-INF/jsp/sso/ssoFailure.jsp"/> </action> <action path="/loginOtherSys" name="ssoSinulateForm" parameter="method" scope="request" type="com.timeson.oa.sso.web.SsoAction"> <forward name="ssoForWard" path="/WEB-INF/jsp/sso/ssoForward.jsp"/> </action> <action path="/getawokeSwitch" name="awokeSwitchForm" parameter="method" scope="request" type="com.timeson.oa.sso.web.TbMenuAction"> <forward name="getSysAwokeSwitch" path="/WEB-INF/jsp/sso/awokeSwitch.jsp"/> </action> <action path="/IniResetpwd" parameter="/WEB-INF/jsp/sso/resetpwd.jsp" type="org.apache.struts.actions.ForwardAction"> </action> <action path="/loginOASys" name="ssoLoginForm" parameter="method" scope="request" type="com.timeson.oa.sso.web.SsoAction"> <forward name="successPro" path="/interFaceList.do?method=index" redirect="true"/> <!--<forward name="success" path="/WEB-INF/jsp/homepage/index.html"/>--> <forward name="success" path="/WEB-INF/jsp/new_homepage/new_index.html"/> <forward name="resetpwd" path="/WEB-INF/jsp/sso/resetpwd.jsp"/> <forward name="changeCompany" path="/WEB-INF/jsp/sso/resetpwd.jsp"/> <forward name="loginMail" path="/WEB-INF/jsp/new_default/loginMail.jsp"/> <forward name="error" path="/WEB-INF/jsp/common/errors.jsp" contextRelative="true" redirect="false"/> <forward name="userList" path="/WEB-INF/jsp/sso/userList.jsp"/> <forward name="switchCompany" path="/WEB-INF/jsp/sso/switchCompany.jsp"/> </action> <action path="/listTbMenu" name="TbMenuForm" parameter="method" scope="request" type="com.timeson.oa.sso.web.TbMenuAction" validate="false" > <forward name="list.success" path="/WEB-INF/jsp/sysmgmt/menu/TbMenuList.jsp"/> <forward name="add" path="/WEB-INF/jsp/sysmgmt/menu/TbMenuForm.jsp"/> </action> <action path="/editTbMenu" name="TbMenuForm" parameter="method" scope="request" type="com.timeson.oa.sso.web.TbMenuAction" validate="false" > <forward name="add" path="/WEB-INF/jsp/sysmgmt/menu/TbMenuForm.jsp"/> <forward name="edit.suceess" path="/WEB-INF/jsp/sysmgmt/menu/TbMenuForm.jsp"/> </action> <action path="/searchLog" name="ssoLoginForm" parameter="method" scope="request" type="com.timeson.oa.sso.web.SsoAction"> <forward name="init" path="/WEB-INF/jsp/homepage/searchLoginLog.jsp"/> <forward name="list" path="/WEB-INF/jsp/homepage/searchLoginLogList.jsp"/> </action> <action path="/lock" name="TbMenuForm" parameter="method" scope="request" type="com.timeson.oa.sso.web.SsoAction"> <forward name="list" path="/WEB-INF/jsp/homepage/lockUser.jsp"/> <forward name="searchList" path="/WEB-INF/jsp/homepage/searchLockUser.jsp"/> <forward name="init" path="/WEB-INF/jsp/homepage/lockSearch.jsp"/> </action> <action path="/eiacLogin" parameter="/WEB-INF/jsp/sso/eiacLogin.jsp" type="org.apache.struts.actions.ForwardAction"/> <action path="/loginOASysEiac" name="TbMenuForm" parameter="method" scope="request" type="com.timeson.oa.sso.web.SsoAction"> <forward name="success" path="/WEB-INF/jsp/new_homepage/eaicIndex.jsp"/> <forward name="infoList" path="/WEB-INF/jsp/new_homepage/eaicInfoList.jsp"/> </action> </action-mappings> </struts-config>
validator-rules.xml
<?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE form-validation PUBLIC "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1//EN" "http://jakarta.apache.org/commons/dtds/validator_1_1.dtd"> <!-- $Header: C:/iConnect/common-files/docroot/WEB-INF/validation-rules/validator-rules.xml,v 1.4 2004/10/14 09:12:03 mcchang Exp $ $Revision: 1.4 $ $Date: 2004/10/14 09:12:03 $ This file contains the default Struts Validator pluggable validator definitions. It should be placed somewhere under /WEB-INF and referenced in the struts-config.xml under the plug-in element for the ValidatorPlugIn. <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> <set-property property="pathnames" value="/WEB-INF/validator-rules.xml, /WEB-INF/validation.xml"/> </plug-in> These are the default error messages associated with each validator defined in this file. They should be added to your projects ApplicationResources.properties file or you can associate new ones by modifying the pluggable validators msg attributes in this file. # Struts Validator Error Messages errors.required={0} is required. errors.minlength={0} can not be less than {1} characters. errors.maxlength={0} can not be greater than {1} characters. errors.invalid={0} is invalid. errors.byte={0} must be a byte. errors.short={0} must be a short. errors.integer={0} must be an integer. errors.long={0} must be a long. errors.float={0} must be a float. errors.double={0} must be a double. errors.date={0} is not a date. errors.range={0} is not in the range {1} through {2}. errors.creditcard={0} is an invalid credit card number. errors.email={0} is an invalid e-mail address. Note: Starting in Struts 1.2.0 the default javascript definitions have been consolidated to commons-validator. The default can be overridden by supplying a <javascript> element with a CDATA section, just as in struts 1.1. --> <form-validation> <global> <validator name="required" classname="org.apache.struts.validator.FieldChecks" method="validateRequired" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest" msg="errors.required"/> <validator name="requiredif" classname="org.apache.struts.validator.FieldChecks" method="validateRequiredIf" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, org.apache.commons.validator.Validator, javax.servlet.http.HttpServletRequest" msg="errors.required"/> <validator name="validwhen" msg="errors.required" classname="org.apache.struts.validator.validwhen.ValidWhen" method="validateValidWhen" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, org.apache.commons.validator.Validator, javax.servlet.http.HttpServletRequest"/> <validator name="minlength" classname="org.apache.struts.validator.FieldChecks" method="validateMinLength" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest" depends="" msg="errors.minlength" jsFunction="org.apache.commons.validator.javascript.validateMinLength"/> <validator name="maxlength" classname="org.apache.struts.validator.FieldChecks" method="validateMaxLength" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest" depends="" msg="errors.maxlength" jsFunction="org.apache.commons.validator.javascript.validateMaxLength"/> <validator name="mask" classname="org.apache.struts.validator.FieldChecks" method="validateMask" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest" depends="" msg="errors.invalid"/> <validator name="byte" classname="org.apache.struts.validator.FieldChecks" method="validateByte" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest" depends="" msg="errors.byte" jsFunctionName="ByteValidations"/> <validator name="short" classname="org.apache.struts.validator.FieldChecks" method="validateShort" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest" depends="" msg="errors.short" jsFunctionName="ShortValidations"/> <validator name="integer" classname="org.apache.struts.validator.FieldChecks" method="validateInteger" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest" depends="" msg="errors.integer" jsFunctionName="IntegerValidations"/> <validator name="long" classname="org.apache.struts.validator.FieldChecks" method="validateLong" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest" depends="" msg="errors.long"/> <validator name="float" classname="org.apache.struts.validator.FieldChecks" method="validateFloat" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest" depends="" msg="errors.float" jsFunctionName="FloatValidations"/> <validator name="double" classname="org.apache.struts.validator.FieldChecks" method="validateDouble" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest" depends="" msg="errors.double"/> <validator name="date" classname="org.apache.struts.validator.FieldChecks" method="validateDate" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest" depends="" msg="errors.date" jsFunctionName="DateValidations"/> <validator name="intRange" classname="org.apache.struts.validator.FieldChecks" method="validateIntRange" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest" depends="integer" msg="errors.range"/> <validator name="floatRange" classname="org.apache.struts.validator.FieldChecks" method="validateFloatRange" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest" depends="float" msg="errors.range"/> <validator name="creditCard" classname="org.apache.struts.validator.FieldChecks" method="validateCreditCard" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest" depends="" msg="errors.creditcard"/> <validator name="email" classname="org.apache.struts.validator.FieldChecks" method="validateEmail" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest" depends="" msg="errors.email"/> <validator name="url" classname="org.apache.struts.validator.FieldChecks" method="validateUrl" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest" depends="" msg="errors.url"/> <!-- This simply allows struts to include the validateUtilities into a page, it should not be used as a validation rule. --> <validator name="includeJavaScriptUtilities" classname="" method="" methodParams="" depends="" msg="" jsFunction="org.apache.commons.validator.javascript.validateUtilities"/> <validator name="twofields" classname="com.timeson.framework.util.ValidationUtil" method="validateTwoFields" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionMessages, javax.servlet.http.HttpServletRequest" depends="required" msg="errors.twofields"> <javascript><![CDATA[ function validateTwoFields(form) { var bValid = true; var focusField = null; var i = 0; var fields = new Array(); var formName = form.getAttributeNode("name"); oTwoFields = eval('new ' + formName.value + '_twofields()'); for (x in oTwoFields) { var field = form[oTwoFields[x][0]]; var secondField = form[oTwoFields[x][2]("secondProperty")]; if (field.type == 'text' || field.type == 'textarea' || field.type == 'select-one' || field.type == 'radio' || field.type == 'password') { var value; var secondValue; // get field's value if (field.type == "select-one") { var s1i = field.selectedIndex; value = field.options[s1i].value; var s2i = secondField.selectedIndex; secondValue = secondField.options[s2i].value; } else { value = field.value; secondValue = secondField.value; } if (value != secondValue) { if (i == 0) { focusField = field; } fields[i++] = oTwoFields[x][1]; bValid = false; } } } if (fields.length > 0) { focusField.focus(); alert(fields.join('\n')); } return bValid; }]]> </javascript> </validator> <constant> <constant-name>phone</constant-name> <constant-value>^\(?(\d{3,4})\)?[-| ]?(\d{3,4})[-| ]?(\d{4})$</constant-value> </constant> <constant> <constant-name>ip</constant-name> <constant-value> ^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$</constant-value> </constant> <constant> <constant-name>zip</constant-name> <constant-value>^\d{5}\d*$</constant-value> </constant> <constant> <constant-name>currency</constant-name> <constant-value>^\d{1,3}(,?\d{1,3})*\.?(\d{1,2})?</constant-value> </constant> <constant> <constant-name>date</constant-name> <constant-value>yyyy-MM-dd</constant-value> </constant> <constant> <constant-name>code</constant-name> <constant-value>^[a-zA-Z0-9]*$</constant-value> </constant> <constant> <constant-name>days</constant-name> <constant-value>^\d{0,7}$</constant-value> </constant> </global> </form-validation>