jp.terasoluna.toursample.common.exception
クラス ApplicationExceptionHandler

java.lang.Object
  上位を拡張 org.apache.struts.action.ExceptionHandler
      上位を拡張 jp.terasoluna.toursample.common.exception.ApplicationExceptionHandler

public class ApplicationExceptionHandler
extends org.apache.struts.action.ExceptionHandler

ApplicationException例外処理クラス。

業務エラー時のログ出力と エラー画面への遷移を行う。
アクション実行中に業務エラーが発生したときは、 エラー情報をログ出力した上で、当該アクションマッピングに定義されている エラー画面に遷移する。 本機能を利用するためには、Struts設定ファイル(struts-config.xml)に グローバル例外、またはアクションレベル例外ハンドラクラスとして指定する。
グローバル例外と、アクションレベル例外が衝突している場合、 Strutsの仕様によりアクションレベル例外が優先される。

グローバル例外としてのシステム例外設定例
Struts設定ファイル(struts-config.xml)に以下のように書く。

 <struts-config>
   …
   <global-exceptions>
     <exception key="some.key"
                path="/error"
                type="jp.terasoluna.toursample.common.exception.ApplicationException"
                className="jp.terasoluna.fw.web.struts.action.ExceptionConfigEx"
                handler="jp.terasoluna.toursample.common.exception.ApplicationExceptionHandler">
       <set-property property="module" value=""/>
     </exception>
   </global-exceptions>
   …
 <struts-config>
 

アクションレベル例外としてのシステム例外設定例

 <struts-config>
   …
   <action path="/start"
           type="jp.terasoluna.xxx.SampleAction"
           name="_sampleForm"
           scope="session">
     <exception key="some.key"
                type="jp.terasoluna.toursample.common.exception.ApplicationException"
                className="jp.terasoluna.fw.web.struts.action.ExceptionConfigEx"
                handler="jp.terasoluna.toursample.common.exception.ApplicationExceptionHandler"
                path="/error.do">
       <set-property property="module" value=""/>
     </exception>
     <forward name="success" path="/index.jsp"/>
   </action>
   …
 <struts-config>
 
なお、<exception>要素のpath属性で遷移先パスが指定 されない場合は、アクションマッピングのinput属性を 転送先リソースとする。

関連項目:
ApplicationException, ExceptionConfigEx

コンストラクタの概要
ApplicationExceptionHandler()
           
 
メソッドの概要
 org.apache.struts.action.ActionForward execute(java.lang.Exception ex, org.apache.struts.config.ExceptionConfig eConfig, org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm formInstance, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          ApplicationException例外ハンドラのエントリポイント。
 
クラス org.apache.struts.action.ExceptionHandler から継承されたメソッド
logException, storeException, storeException
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

ApplicationExceptionHandler

public ApplicationExceptionHandler()
メソッドの詳細

execute

public org.apache.struts.action.ActionForward execute(java.lang.Exception ex,
                                                      org.apache.struts.config.ExceptionConfig eConfig,
                                                      org.apache.struts.action.ActionMapping mapping,
                                                      org.apache.struts.action.ActionForm formInstance,
                                                      javax.servlet.http.HttpServletRequest request,
                                                      javax.servlet.http.HttpServletResponse response)
                                               throws javax.servlet.ServletException
ApplicationException例外ハンドラのエントリポイント。

オーバーライド:
クラス org.apache.struts.action.ExceptionHandler 内の execute
パラメータ:
ex - 例外
eConfig - 例外コンフィグ
mapping - アクションマッピング
formInstance - アクションフォーム
request - HTTPリクエスト
response - HTTPレスポンス
戻り値:
エラーメッセージ
例外:
javax.servlet.ServletException - サーブレット例外