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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值