`

Spring配置之ActionContextCleanUp

阅读更多
参考:
ActionContextCleanUp的作用:http://blog.csdn.net/oyxm0/article/details/7360214

涉及类:org.apache.struts2.dispatcher.ActionContextCleanUp

一、说明
在Struts 2.1.6之前,ActionContextCleanUp的完整路径是com.opensymphony.webwork.dispatcher.ActionContextCleanUp,现在的路径变成了org.apache.struts2.dispatcher.ActionContextCleanup。
延长action中属性的生命周期,包括自定义属性,以便在jsp页面中进行访问,让actionContextcleanup过滤器来清除属性,不让action自己清除。

     那么这个类究竟有什么用处呢?是不是一定要用呢?

     下面是这个类内部的注释。

     Special filter designed to work with the FilterDispatcher and allow
for easier integration with SiteMesh. Normally, ordering your filters to have
SiteMesh go first, and then FilterDispatcher go second is perfectly fine.
However, sometimes you may wish to access Struts features, including the value stack, from within your SiteMesh decorators. Because FilterDispatcher
cleans up the ActionContext, your decorator won't have access to the
data you want.
     By adding this filter, the FilterDispatcher will know to not clean up and instead defer cleanup to this filter. The ordering of the filters should then be:
1.this filter

2.SiteMesh filter

3.FilterDispatcher

    就是说,一般情况下,如果你要用SiteMesh或者其他过滤器,一般是放在FilterDispatcher或者是现在的StrutsPrepareAndExecuteFilter之前。在调用完所有过滤器的doFilter方法后,核心过滤器FilterDispatcher或者StrutsPrepareAndExecuteFilter会清空ActionContext,如果其他过滤器要一直使用value stack等struts的特性时,如果不用ActionContextCleanUp的话,便得不到想要的值。
    ActionContextCleanUp的作用就是上面用粗体标注出来的那一句。它会在doFilter方法里设置一个计数器counter的初始值为1,有了这个值,后续的核心过滤器就不会清空ActionContext,而是由之前的过滤器也就是ActionContextCleanUp来清空ActionContext。


什么是valuestack?http://hi.baidu.com/c%B3%E6c%B3%E6/blog/item/c8f63518e77fbe028718bf56.html

分享到:
评论

相关推荐

    解决struts2.1.6+spring+hibernate 中文乱码

    web.xml(仅写出中文处理部分,spring的配置不用改变) <filter-name>encodingFilter <filter-class>org.springframework.web.filter.CharacterEncodingFilter <init-param> <param-name>encoding...

    Struts2整合SiteMesh技巧

    注意ActionContextCleanUp过滤器必须在FilterDispatcher之前配置,ActionContextCleanUp的主要功能是通知FilterDispatcher执行完毕不要清除ActionContext,以便sitemesh装饰器可以访问Struts值堆栈。 配置装饰器 ...

    SSH的jar包.rar

    2、这个请求经过一系列的过滤器(Filter)(这些过滤器中有一个叫做ActionContextCleanUp的可选过滤器,这个过滤器对于Struts2和其他框架的集成很有帮助,例如:SiteMesh Plugin) 3、接着FilterDispatcher被调用,...

    robot framework 2.5.30 版本用户手册资料整理 中文版

    Robot Framework user guider资料和使用注意事项,整理资料,主要包括RF的用法和使用注意事项文档资料、测试用例编写、用户关键字定义等

    Struts2的工作原理和流程

    2 这个请求经过一系列的过滤器(Filter)(这些过滤器中有一个叫做ActionContextCleanUp的可选过滤器,这个过滤器对于Struts2和其他框架的集成很有帮助,例如:SiteMesh Plugin) 3 接着FilterDispatcher被调用,...

    struts2流程与流程图

     请求被提交到一系列(主要是3层)的过滤器(Filter),如(ActionContextCleanUp、其他过滤器(SiteMesh等)、 FilterDispatcher)。注意:这里是有顺序的,先ActionContext CleanUp,再其他过滤器(Othter ...

    struts2开发文档

    ActionContextCleanUp的可选过滤器,这个过滤器对于Struts2和其他框 架的集成很有帮助,例如:SiteMesh Plugin) 3 接着FilterDispatcher被调用,FilterDispatcher询问ActionMapper来 决定这个请是否需要调用某个...

    Struts2请求处理流程及源码分析

    b)根据Web.xml配置,请求首先经过ActionContextCleanUp过滤器,其为可选过滤器,这个过滤器对于Struts2和其他框架的集成很有帮助(SiteMeshPlugin),主要清理当前线程的ActionContext和Dispatcher;c)请求经过插件...

    解决struts2下载异常的jar包 struts2-sunspoter-stream-1.0.jar

    235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:102) at org....

    Struts2源码分析

    Struts2源码分析 请求首先通过Filter chain,Filter 主要包括ActionContextCleanUp,它主要清理当前线 程的ActionContext 和Dispatcher;FilterDispatcher 主要通过AcionMapper 来决定需要调用哪 个Action。

    struts PPT讲解

    工作流程当接收到一个httprequest  Interceptor做一些拦截或者初始的工作  当外部的httpservletrequest到来时  初始到了servlet容器 传递给一个标准的过滤器链  ActionContextCleanUp这个在集成插件方面非常有

    Java Struts 实现拦截器

    • 客户端产生一个HttpServletRequest的请求,该请求被提交到一系列的标准过滤器(Filter)组建链中(如ActionContextCleanUp:它主要是清理当前线程的ActionContext、Dispatcher,FilterDispatcher主要是通过...

    java中文乱码解决方案

    -- zh-cn encoding --> <filter> <filter-name>struts-cleanup </filter-name> <filter-class> org.apache.struts2.dispatcher.ActionContextCleanUp </filter-class> </filter> ...

Global site tag (gtag.js) - Google Analytics