<body>
<s:form action="user/tologin.action" method="post">
<s:textarea name="id"></s:textarea>
<s:password name="user.password"></s:password>
<s:textfield name="user.name" label="ddddd" > </s:textfield>
<s:submit value="提交" method="login"></s:submit>
<s:submit value="打印" method="print"></s:submit>
</s:form>
</body>
验证框架的命名规则是Action类名字-action的bean名字-validation.xml,这个验证文件需要放在需要验证的.class文件同一目录下
例如UserAction-tologin-validation.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC
"-//Apache Struts//XWork Validator 1.0.2//EN"
"http://struts.apache.org/dtds/xwork-validator-1.0.2.dtd">
<validators>
<field name="id">
<field-validator type="int">
<param name="min">10</param>
<param name="max">20</param>
<message>必须是整数</message>
</field-validator>
</field>
<field name="user.name">
<field-validator type="requiredstring">
<message>name必须填写</message>
</field-validator>
</field>
</validators>
在struts-xml中的配置
<action name="tologin" class="UserAction" >
<result>/WEB-INF/user/list.jsp</result>
<result name="input">/WEB-INF/user/user.jsp</result>
</action>