閱讀134 返回首頁    go 阿裏雲 go 技術社區[雲棲]


為struts2中自己實現webwork2中的AroundInterceptor攔截器

package com.yanek.util;


import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public abstract class AroundInterceptor
  implements Interceptor
{
  protected transient Log log;

  public AroundInterceptor()
  {
    this.log = LogFactory.getLog(super.getClass()); }

  public void destroy() {
  }

  public void init() {
  }

  public String intercept(ActionInvocation invocation) throws Exception {
    String result = null;

    before(invocation);
    result = invocation.invoke();
    after(invocation, result);

    return result;
  }

  protected abstract void after(ActionInvocation paramActionInvocation, String paramString)
    throws Exception;

  protected abstract void before(ActionInvocation paramActionInvocation)
    throws Exception;
}

 

實現它:可以處理action執行前,執行後的攔截處理

 

最後更新:2017-04-02 03:42:36

  上一篇:go 數據庫主鍵生成器java代碼
  下一篇:go 一種表單重複提交處理方法