Struts 拦截器
public String intercept(ActionInvocation invocation) {
//do some job before invocation
//...
String result = invocation.invoke();
//do some job after invocation
//...
return result;
}
使用自定义的Interceptor时,一定要定义一个Interceptor栈,定义你自己的拦截器和系统默认拦截器的调用顺序,如果直接在 action中引用你自定义的拦截器,就会发现只调用了你自己的拦截器,没有调用Struts2中内置的拦截器,那样有很多功能就会运行不正常了。
<interceptors>
<interceptor name="authorize" class="com.struts2.interceptor.AuthorizeInterceptor" />
<interceptor-stack name="appStack">
<!-- 你自定义的 -->
<interceptor-ref name="authorize"/>
<!-- 系统内置的拦截器栈 -->
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>
<action name="forward" class="com.struts2.RequestForward">
<interceptor-ref name="appStack"/>
<result name="index">index.jsp</result>
<result name="NOT_FOUND">not_found.jsp</result>
</action>
另附上保存Cookie:http://www.iteye.com/topic/149260
你实现的方法
1.public String intercept(ActionInvocation invocation) {
2. //do some job before invocation
3. //...
4. String result = invocation.invoke();
5. //do some job after invocation
6. //...
7. return result;
8. }
is class "com.struts2.interceptor.AuthorizeInterceptor" 的 方法吧?