ExceptionMappingInterceptor を拡張しようとしています。ExceptionMappingInterceptor の publishException(...) メソッドをオーバーライドするリスナーを作成しました。ただし、アプリケーションで処理されないグローバル例外はリッスンしていません。
これが私の構成です。
//ハンドラ
public class GlobalExceptionHandler extends ExceptionMappingInterceptor
{
private Logger logger = AppLogger.getLogger(this.getClass());
@Override
protected void publishException(ActionInvocation invocation, ExceptionHolder exceptionHolder)
{
logger.error("Global Exception msg: "+ exceptionHolder.getException().getMessage(), exceptionHolder.getException());
super.publishException(invocation, exceptionHolder);
}
}
struts.xml 内
<interceptors>
<interceptor name="sessionInterceptor" class="com.jak.session.SessionInterceptor" />
<interceptor name="exception" class="com.jak.exception.GlobalExceptionHandler" />
<interceptor-stack name="mymatrixxInterceptorStack">
<interceptor-ref name="exception"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
<interceptor-ref name="sessionInterceptor"/>
</interceptor-stack>
</interceptors>
<global-results>
<result name="exception" type="tiles">myAccount</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="exception" />
</global-exception-mappings>
<action name="myAccount">
<interceptor-ref name="mymatrixxInterceptorStack"></interceptor-ref>
<result type="tiles">errorPage</result>
</action>
ファイルのアップロード中に、「アクション com.dsdar.business.offer.CampaignUpdateAction および結果入力に対して結果が定義されていません」という例外が発生しました。ただし、この例外はこのインターセプターでは処理されません。聞いていない理由はわかりません。