编写的validation.xml文件针对的是单个的action
命名格式为:action的名字-validation.xml
eg:LoginAction-validation.xml
编写的validation.xml文件式针对某个action里面的特定一个方法
eg:
UserAction
public class UserAction extends ActionSupport implements ModelDriven<User> {
private static final long serialVersionUID = 1L;
private User user = new User();
@Override
public User getModel() {
// TODO Auto-generated method stub
return user;
}
public String login() throws Exception {
if() {
return SUCCESS;
} else {
return ERROR;
}
}
public String regist() throws Exception {
if () {
return SUCCESS;
} else{
return INPUT;
}
}
}
struts.xml
<package name="user" namespace="/" extends="struts-default">
<action name="UserAction_login" class="ssh.excise.action.UserAction" method="login">
<result name="success">/index.jsp</result>
<result name="input">/login.jsp</result>
</action>
<action name="UserAction_regist" class="ssh.excise.action.UserAction" method="regist">
<result name="success">/login.jsp</result>
<result name="input">/regist.jsp</result>
</action>
</package>
只需要校验register方法时
method=“regist” 对应的name值为UserAction_regist
所以校验文件的名字是UserAction-UserAction_regist-validation.xml
命名格式:action的名字-struts.xml中该方法配置的name值-validation.xml