06-11
26
Validator的isEmail验证
作者:Java伴侣 日期:2006-11-26
内部实现的方法
import org.apache.struts.validator.FieldChecks;
FieldChecks.validateEmail( );//中有5个参数,一一传入,判断是否为boolean型
Validator中实现机制:validator-rules.xml
<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"/>
自写的validation.xml:
<field property="mail" depends="email">
<arg0 key="lable.emp.mail"/>
</field>
注意一点,email的验证只验证格式正确与否,对required不敏感。
import org.apache.struts.validator.FieldChecks;
FieldChecks.validateEmail( );//中有5个参数,一一传入,判断是否为boolean型
Validator中实现机制:validator-rules.xml
<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"/>
自写的validation.xml:
<field property="mail" depends="email">
<arg0 key="lable.emp.mail"/>
</field>
注意一点,email的验证只验证格式正确与否,对required不敏感。
评论: 0 | 引用: 0 | 查看次数: 683
发表评论