为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执行前,执行后的拦截处理

你可能感兴趣的:(Interceptor)