struts2服务器端自动验证

UserAction-register-validation.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
<validators>
<field name="user.username">
<field-validator type="requiredstring" short-circuit="true">
<param name="trim">true</param>
<message>用户名不能为空</message>
</field-validator>
<field-validator type="stringlength" short-circuit="true">
<param name="minLength">6</param>
<param name="maxLength">20</param>
<message>用户名字符数应该在${minLength}到${maxLength}之间</message>
</field-validator>
</field>

<field name="user.password">
<field-validator type="requiredstring" short-circuit="true">
<param name="trim">true</param>
<message>密码不能为空</message>
</field-validator>
<field-validator type="stringlength" short-circuit="true">
<param name="minLength">6</param>
<param name="maxLength">20</param>
<message>用户名字符数应该在${minLength}到${maxLength}之间</message>
</field-validator>
</field>


</validators>

你可能感兴趣的:(xml)