Struts2.x快速上手7--声明式验证(validation.xml)

1)logon.jsp
 使用struts2标记

 

2)在Action下添加同名的校验配置

LogonAction-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="username">
  <field-validator type="requiredstring">
   <message key="username.required"></message>
  </field-validator>
 </field>
 <field name="password">
  <field-validator type="requiredstring">
   <message key="password.required"></message>
  </field-validator>
 </field>
</validators>

你可能感兴趣的:(xml,jsp)