struts框架校验,为什么没通过校验直接执行excute方法?
public class Register extends ActionSupport{private String username;
private String password;
private String password1;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getPassword1() {
return password1;
}
public void setPassword1(String password1) {
this.password1 = password1;
}
public String execute() throws Exception {
return "su";
}
}
配置:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
"http://www.
<validators>
<field name="username">
<field-validator type="requiredstring" short-circuit="true">
<param name="trim">true</param>
<message>用户名不能为空</message>
</field-validator>
<field-validator type="stringlength">
<param name="minLength">6</param>
<param name="maxLength">10</param>
<message>用户名必须在${minLength} 和 ${maxLength}之间</message>
</field-validator>
</field>
<field name="password">
<field-validator type="stringlength">
<param name="minLength">6</param>
<param name="maxLength">10</param>
<message>用户名必须在${minLength} 和 ${maxLength}之间</message>
</field-validator>
<field-validator type="requiredstring" short-circuit="true">
<param name="trim">true</param>
<message>密码不能为空</message>
</field-validator>
</field>
<field name="password1">
<field-validator type="stringlength">
<param name="minLength">6</param>
<param name="maxLength">10</param>
<message>用户名必须在${minLength} 和 ${maxLength}之间</message>
</field-validator>
<field-validator type="requiredstring" short-circuit="true">
<message>确认密码</message>
</field-validator>
<field-validator type="fixeldexpressio">
<param name="expression">password==password1</param>
<message>确认密码和密码不一致</message>
</field-validator>
</field>
</validators>