创建拦截器类,第三种就是继承AbstractInterceptor类,该类是实现了Interceptor接口的,如下:
package com.xbb.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
public class SecondInterceptor extends AbstractInterceptor {
@Override
public String intercept(ActionInvocation invocation) throws Exception {
// TODO Auto-generated method stub
System.out.println("second interceptor");
String result = invocation.invoke();
System.out.println("second reslut:" + result);
return result;
}
}
其他配置和使用与前面无异。