深入struct2拦截器
来源:互联网 发布:如何保持身材 知乎 编辑:程序博客网 时间:2024/05/16 05:28
这篇文章很好,细致讲解了structs2和拦截器的原理。
http://zhanghong.iteye.com/blog/452465
配置拦截器:Struts2中提供了大量的拦截器,多个拦截器可以组成一个拦截器栈,系统配置了一个默认的拦截器栈 defaultStack,具体包括那些拦截器以及顺序可以在struts-default.xml中找到。
1)
<package name="default" extends="struts-default">
<interceptors>
<interceptor name="timer" class=".."/>
<interceptor name="logger" class=".."/>
</interceptors>
<action name="login"
class="tutorial.Login">
<interceptor-ref name="timer"/>
<interceptor-ref name="logger"/>
<result name="input">login.jsp</result>
<result name="success"
type="redirectAction">/secure/home</result>
</action>
</package>
2)
<package name="default" extends="struts-default">
<interceptors>
<interceptor name="timer" class=".."/>
<interceptor name="logger" class=".."/>
<interceptor-stack name="myStack">
<interceptor-ref name="timer"/>
<interceptor-ref name="logger"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>
<action name="login"
class="tutuorial.Login">
<interceptor-ref name="myStack"/>
<result name="input">login.jsp</result>
<result name="success"
type="redirectAction">/secure/home</result>
</action>
</package>
拦截器执行顺序:
<interceptor-stack name="xaStack">
<interceptor-ref name="thisWillRunFirstInterceptor"/>
<interceptor-ref name="thisWillRunNextInterceptor"/>
<interceptor-ref name="followedByThisInterceptor"/>
<interceptor-ref name="thisWillRunLastInterceptor"/>
</interceptor-stack>
执行顺序:
thisWillRunFirstInterceptor
thisWillRunNextInterceptor
followedByThisInterceptor
thisWillRunLastInterceptor
MyAction1
MyAction2 (chain)
MyPreResultListener
MyResult (result)
thisWillRunLastInterceptor
followedByThisInterceptor
thisWillRunNextInterceptor
thisWillRunFirstInterceptor
自定义拦截器:必须实现 com.opensymphony.xwork2.interceptor.Interceptor 也可以继承 AbstractInterceptor
拦截器要保证线程安全。因为structs2中拦截器会在请求间共享
1)
<package name="default" extends="struts-default">
<interceptors>
<interceptor name="timer" class=".."/>
<interceptor name="logger" class=".."/>
</interceptors>
<action name="login"
class="tutorial.Login">
<interceptor-ref name="timer"/>
<interceptor-ref name="logger"/>
<result name="input">login.jsp</result>
<result name="success"
type="redirectAction">/secure/home</result>
</action>
</package>
2)
<package name="default" extends="struts-default">
<interceptors>
<interceptor name="timer" class=".."/>
<interceptor name="logger" class=".."/>
<interceptor-stack name="myStack">
<interceptor-ref name="timer"/>
<interceptor-ref name="logger"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>
<action name="login"
class="tutuorial.Login">
<interceptor-ref name="myStack"/>
<result name="input">login.jsp</result>
<result name="success"
type="redirectAction">/secure/home</result>
</action>
</package>
拦截器执行顺序:
<interceptor-stack name="xaStack">
<interceptor-ref name="thisWillRunFirstInterceptor"/>
<interceptor-ref name="thisWillRunNextInterceptor"/>
<interceptor-ref name="followedByThisInterceptor"/>
<interceptor-ref name="thisWillRunLastInterceptor"/>
</interceptor-stack>
执行顺序:
thisWillRunFirstInterceptor
thisWillRunNextInterceptor
followedByThisInterceptor
thisWillRunLastInterceptor
MyAction1
MyAction2 (chain)
MyPreResultListener
MyResult (result)
thisWillRunLastInterceptor
followedByThisInterceptor
thisWillRunNextInterceptor
thisWillRunFirstInterceptor
自定义拦截器:必须实现 com.opensymphony.xwork2.interceptor.Interceptor 也可以继承 AbstractInterceptor
拦截器要保证线程安全。因为structs2中拦截器会在请求间共享
- 深入struct2拦截器
- Struct2 自定义拦截器
- struct2 的拦截器
- Struct2 自定义拦截器
- struct2拦截器
- Struct2拦截器的原理与实现
- struct2登录拦截器的配置
- struct2中得默认拦截器(类似AOP)
- struct2中得自定义拦截器(类似AOP)
- 教务管理系统-Struct2注解使用拦截器(Interceptor)
- 深入Struts2拦截器
- 深入struts2拦截器
- 深入Struts拦截器
- 深入Struts2拦截器
- SpringMVC拦截器深入
- 理清jsp的filter(过滤器)和struct2的拦截器(Interceptor)
- Struct2
- struct2
- AS3.0 几何结构 Point对象和Rectangle对象
- Notify_module和ArchIpcInt_object
- 关于C++中string输入cin,getline()问题,《C++ primer》学习总结
- 编程之美-中国象棋将帅问题
- Java 保存 Unicode 文件
- 深入struct2拦截器
- Notify_registerEvent的实现过程
- 求数组中连续子数组的最大和
- 中断响应后函数调用
- 中断注册函数整理
- CCFadeOut的使用感想
- TOMCAT JVM调优
- java stop thread
- ASP.NET(C#)常用数据加密和解密方法汇总