1、global-exception-mappings:配置之后,如果项目中用到自定义的MethodFilterInterceptor子类,会导致MethodFilterInterceptor等拦截器在拦截过程无法catch到异常信息,无法打log,很难排错。最近的项目是用了guice的,一开始还担心是不是guice导致的问题,最后引入strust2的源码debug过程才发现是配置了global-exception-mappings导致的,完全没想到是这个原因。
2、excludeMethods:使用了该配置的action,需要根据实际情况在action内显式使用try catch来捕获未预想到的异常,因为一旦excludeMethods,那就是不会经过自定义的全局拦截的Interceptor了,错误日志无法记录。
<global-exception-mappings>
<exception-mapping result="error" exception="java.lang.Exception" />
</global-exception-mappings>
2、excludeMethods:使用了该配置的action,需要根据实际情况在action内显式使用try catch来捕获未预想到的异常,因为一旦excludeMethods,那就是不会经过自定义的全局拦截的Interceptor了,错误日志无法记录。
<action name="login" class="xxx.ABCAction" method="login">
<interceptor-ref name="optionalInteceptor">
<param name="excludeMethods">*</param>
</interceptor-ref>
<interceptor-ref name="defaultStack" />
<result name="success" type="redirectAction">
<param name="actionName">xx</param>
<param name="namespace">/</param>
</result>
<result name="input">/index.jsp</result>
</action>