struts2---Error message的显示

//@Override
   public void validateDoLogin() {
     if(null == loginname || loginname.isEmpty()){
      addFieldError("loginname", "登录名不能为空!");
      this.addActionError("处理动作失败!");
     }else if(null == loginpwd || loginpwd.isEmpty())
      addFieldError("loginpwd", "密码不能为空!");
     else if( ! "admin".equals(getLoginname())){
             addFieldError("loginname", "登录名不正确!");
         }else if(! "pwd".equals(getLoginpwd())){
             addFieldError("loginpwd", "密码不正确!");
         }
     }

 

 

<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>    <title>login</title>  </head>
  <body>
   <s:actionerror/>
   <s:actionmessage/>
 
   <form action="login_login.action" method="post">
  user Name:<input name="loginname" type="text" value="admin"><s:fielderror fieldName="loginname" />
  <br>
  pwd:<input type="password" name="loginpwd" value="pwd"><s:fielderror fieldName="loginpwd" /><br>
  <input type="submit" value="submit">
  </form>

  </body>
</html>

posted @ 2011-01-07 17:05  Java Oracle SQL技术  阅读(2477)  评论(0编辑  收藏  举报