使用struts2 validation框架进行form验证
<!DOCTYPE validators PUBLIC
?"-//OpenSymphony Group//XWork Validator1.0.2//EN"
?"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
<validators>??
<fieldname="user.strUsername">??
?? <!-- 验证字符串不能为空-->??
??<field-validatortype="requiredstring">??
???<!-- 去空格-->??
???<paramname="trim">true</param>??
???<!-- 错误提示信息-->??
???<message>用户名不能为空</message>??
??</field-validator>??
????
?? <!-- 验证字符串长度-->??
??<field-validatortype="stringlength">??
???<paramname="minLength">2</param>??
???<paramname="maxLength">20</param>??
???<message>用户名长度应在2到18个字符间</message>??
??</field-validator>??
</field>??
?
<fieldname="user.strPassword">??
??<field-validatortype="requiredstring">??
???<paramname="trim">true</param>??
???<message>密码不能为空</message>??
??</field-validator>??
????
??<field-validatortype="stringlength">??
???<paramname="minLength">6</param>??
???<paramname="maxLength">18</param>??
???<message>密码长度应在6到18个字符之间</message>??
??</field-validator>??
</field>??
?
<!--<fieldname="user.age">??
??<field-validatortype="int">??
???<paramname="min">1</param>??
???<paramname="max">150</param>??
???<message>年龄应在1到150之间<//a> 2010-04-08 16:23 浏览 545 评论(0) 分类:企业架构