1. 建立自己的拦截器
public class MyInterceptor implements Interceptor {
void destroy();
void init();
String intercept(ActionInvocation invocation) throws Exception {
// 实现逻辑
}
}
struts 中对ActionInvocation的说明是包含了各级的Interceptor和最终的action.但是在拦截器中是如何被依次按顺序调用的暂时不知道.等待后续研究.
2.配置我的拦截器
在struts.xml中
<interceptor> <interceptor name="" class=""> </interceptor> <package namespace="" name="" extends="struts-default"> <action name="default" class=""> <result>/index.jsp</result> <interceptor-ref name=""> <param name="name">拦截器1</param> </interceptor-ref> </action> </package>