验证框架
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.3//EN" "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> <validators> <!-- 用户名的验证 --> <field name="u.uname"> <field-validator type="requiredstring"> <param name="trim">true</param> <message key="name.null"/> </field-validator> <field-validator type="stringlength"> <param name="minLength">6</param> <param name="maxLength">10</param> <message key="name.length" /> <!-- <message >用户名长度必须保证在${minLength}到${maxLength}之间</message> --> </field-validator> </field> <field name="u.upwd"> <field-validator type="requiredstring"> <param name="trim">true</param> <!-- <message>密码不能为空</message> --> <message key="pwd.null" /> </field-validator> <field-validator type="stringlength"> <param name="minLength">6</param> <!-- <message>密码长度必须大于${minLength}位</message> --> <message key="pwd.length" /> </field-validator> </field> <field name="uRpwd"> <field-validator type="fieldexpression"> <param name="expression">u.upwd==uRpwd</param> <message>确认密码和密码不一致</message> </field-validator> </field> <field name="u.email"> <field-validator type="regex"> <param name="regex"> ^\w+@\w+\.[a-zA-Z]{2,3}(.[a-zA-Z]{2,3})?$ </param> <message>邮箱格式不正确</message> </field-validator> </field> <field name="u.age"> <field-validator type="required"> <param name="trim">true</param> <message>年龄不能为空</message> </field-validator> <field-validator type="int"> <param name="min">0</param> <param name="max">150</param> <message>年龄必须${min}-${max}之间</message> </field-validator> </field> </validators>