我怎么把Action 里的request.setAttribute("Mess","错误的姓名或密码");返回到JSP显示出来

解决方案 »

  1.   

    按你上面的做法,把
    <forward name="failure" path="/login.jsp" redirect="true"></forward>         
     <forward name="success" path="/dex.jsp" redirect="true" />
    里的redirect属性设置为false,这样你在jsp页面才能用request.getAttribute("Mess")取到这个值.
      

  2.   

    但是更好的做法是在execute方法里这样处理验证:
    ActionErrors errors=new ActionErrors();
    if(na.equals("Mark") && ps.equals("123456")){}else{
       lf.reset(mapping,request);
       errors.add("error.password", new ActionError("error.password.error"));
       this.saveErrors(request,errors);
       return (mapping.findForward("failure"));}
    return (mapping.findForward("success"));
    =====================================================
    资源文件里加一条:error.password.error=错误的姓名或密码
    在JSP页面<html:errors property="error.password"/>