表单验证错误信息未显示
struts配置
<package name="users" namespace="/users" extends="default">
<action name="*_*" class="action.{1}Action" method="{2}">
<result name="input">/users/Users_login.jsp</result>
<result name="login_success">/users/Users_login_success.jsp</result>
<result name="login_failure">/users/Users_login.jsp</result>
<result name="logout_success">/users/Users_login.jsp</result>
</action>
</package>
Action
@SkipValidation
public String login(){
UsersDao udao=new UsersDaoImpl();
if(udao.usersLogin(u)){
//在session中保存
session.setAttribute("loginUserName", u.getUsername());
return "login_success";
}else
return "login_failure";
}
@Override
public void validate() {
//用户名不能为空
if("".equals(u.getUsername())){
this.addFieldError("usernameError", "用户名不能为空!");
}
if(u.getPassword().length()<6){
this.addFieldError("password", "密码长度不能少于6位!");
}
}
哪里不对了呢