本人写了个小网站,后来调试的时候没有处理异常
但是对异常处理没有太大的要求,只要在客户端不要显示异常信息就行了web.xml里面添加,处理不通过struts2框架的异常
<error-page>
        <error-code>404</error-code>
        <location>/404.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/500.jsp</location>
</error-page>struts.xml中添加,由于action抛出Exception,和默认的action,这样够了吧
<package name="default" extends="struts-default">
<global-results>
<result name="allException">/views/exceptions.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping result="allException" exception="java.lang.Exception" />
</global-exception-mappings>
<action name="*">
<result>/views/exceptions.jsp</result>
</action>
</package>这是我自己琢磨出来的,可能有不符合的地方,请大家提意见。