我没进过软件公司做过。不知道 显示层的异常是用struts2的异常拦截器,还是自己在action里try catch到自己定义的异常系统里,然后在web.xml配置,把自ApplicationException导向固定错误页面;
在自定义错误哪,记录日志;
不用struts2的异常处理,不知道可以不,我项目用的ssh2框架,望帮助,谢谢 strutsactionssh异常处理

解决方案 »

  1.   

    如果不拦截异常页面显示的就是500错误,效果还是一样的。
    说真的,不是很理解“不用struts2的异常处理”这句话的意思,你想要的具体效果是什么?能说说么
      

  2.   

    struts2的异常拦截器,我业务逻辑是自定义异常 ApplicationException,都往外抛出来了的;在action里 我想用try catch住 
    导向固定错误页面
    <!-- 定义错误页面 -->
    <error-page>
      <exception-type>com.xxx.util.ApplicationException</exception-type>
      <location>/system_error.jsp</location>
    </error-page><error-page>
    <error-code>404</error-code>
    <location>/http_error404.jsp</location>
    </error-page><error-page>
    <error-code>500</error-code>
    <location>/http_error505.jsp</location>
    </error-page>不知道action用不用处理异常,我要输出异常日志记录
      

  3.   

    不用struts2的异常处理,不知道可以不完全可以啊,你直接输出错误信息就可以了,如response.getWriter().write("error")
      

  4.   

    噢,谢谢,每个action里,可不可以都用try catch住异常try
       {

    if(username == null || username.equals(""))
             {
        return INPUT;
      }
    if(passwd == null || passwd.equals(""))
     {
      return INPUT;
     }
    User user = service.findUserByName(username);

    if(user != null )
          {             if(MD5Pass.MD5(passwd).equals(user.getUserpasswd()))                           
    {
      request.getSession().setAttribute("user", user);
      return SUCCESS;
     }

     }
    return INPUT;
    }
        catch (Exception e)
         {
    throw new ApplicationException("系统繁忙,请稍后再试!");
         }
      

  5.   

    我就想知道你们项目用struts2,异常是struts2的申明式异常处理,还是自己每个action 都 try catch住
      

  6.   

    <package name="exceptionTest" extends="struts-default" namespace="/">
    <global-results>
    <result name="sql">/exception.jsp</result>
    <result name="root">/exception.jsp</result>
    </global-results>
    <global-exception-mappings>
    <exception-mapping result="sql" exception="java.sql.SQLException"></exception-mapping>
    <exception-mapping result="root" exception="java.lang.Exception"></exception-mapping>
    </global-exception-mappings> <action name="exceptionTestAction" class="ExceptionTestAction">
    <exception-mapping result="my"
    exception="MyException"></exception-mapping>
    <result name="my">/exception.jsp</result>
    <result name="error">/error.jsp</result>
    <result name="success">/welcome.jsp</result>
    </action>
    </package>
      

  7.   

    Struts2有自己的异常处理机制,可以再Struts.xml里面配置异常。不过项目中一般不会这么用吧
      

  8.   

    试一下不就知道了可能可以,struts异常处理机制无非也是try catch的,而现在如果自己捕获,如果晚于它捕获异常,就能自己处理,否则仍可能会抛给struts的异常处理系统