<h1><p>
    <html:errors/>
   </p>
         </h1>是这样写的吗?

解决方案 »

  1.   

    return mapping.getInputForward();你有向错误页面提交什么东西吗 ?
      

  2.   

    try{
          if(LoginService.login(userName,password)){
            String cnName=LoginService.getCnNameByName(userName);
            request.getSession().setAttribute("userName",userName);
            request.getSession().setAttribute("userCnName",cnName);
            return mapping.findForward("success");
          }else{
          return mapping.getInputForward();
          }    }catch(Exception e){
          System.err.println("用户'"+userName+"'从"+ip+"登录到系统失败:"+e.getMessage());
        }
        return mapping.findForward("fail");
      } 
    这样的话是不能返回error的,(其实返回没我不知道,但是不会显示)
    但是如果把try的那层去掉的话就可以了 我不知道原因~望各位说明下
     if(LoginService.login(userName,password)){
            String cnName=LoginService.getCnNameByName(userName);
            request.getSession().setAttribute("userName",userName);
            request.getSession().setAttribute("userCnName",cnName);
            return mapping.findForward("success");
          }else{
          return mapping.getInputForward();
    (这样能够显示error)
      

  3.   

    为什么我没看见ActionErrors或是ActionMessages类呢?没有它们并saveErrors()或saveMessages(),返回页面就能出错误提示?
      

  4.   

    我用的是validator,是通过xml来生成error的
      

  5.   

    xml生成error?那error什么时候出现有设定码?莫非在xml里写代码?有点夸张了。。
      

  6.   

    ``只要没有通过验证  就会自动添加error,xml指定验证的类型,resources里面写错误信息。
      

  7.   

    会调用一些包里的方法来实现,具体你可以参考下struts的validator,我现在的问题不是如何生成的error,而是在try里面无法显示,而去掉try就行。
      

  8.   

    察看规则是否正确
    及resource中是否有相关错误提示