interceptor

作成から使用までの流れ

  1. com.opensymphony.xwork2.interceptor.Interceptorを実装したクラスを作成。
     ※com.opensymphony.xwork2.interceptor.AbstractInterceptorでもよい
  2. intercept(ActionInvocation)に処理を記述する。
  3. struts.xmlにinterceptorを登録する。
  4. struts.xmlにinterceptorを使用する箇所を記述する。
  5. 上手にできましたー♪



Interceptor実装クラスの注意

  • 戻り値はActionInvocation#invoke()を指定する。
    • そうしないと次の処理に遷移しないよ。



struts.xmlの記述方法

  1. タグの要素にタグを追加。
  2. タグの要素にを追加。
    1. タグのname属性にinterceptorの名前を書く。
    2. タグのclass属性に、com.opensymphony.xwork2.interceptor.Interceptorを登録したクラスを指定する。



  • イメージ

    
        
    



使用方法

  1. struts.xmlタグの要素にを追加。
    1. のname属性に、使用するinterceptor名(タグのname属性)を書く。
  2. 上手にできましたー♪



  • イメージ