在Struts 2.1.6之前,ActionContextCleanUp的完整路径是com.opensymphony.webwork.dispatcher.ActionContextCleanUp,现在的路径变成了org.apache.struts2.dispatcher.ActionContextCleanup。
那么这个类究竟有什么用处呢?是不是一定要用呢?
下面是这个类内部的注释。
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。
转自:http://changli269.iteye.com/blog/928190
分享到:
相关推荐
at org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper.cleanUp(MultiPartRequestWrapper.java:271) at org.apache.struts2.dispatcher.Dispatcher.cleanUpRequest(Dispatcher.java:837) at org....
struts1和struts2的区别struts1和struts2的区别struts1和struts2的区别struts1和struts2的区别struts1和struts2的区别struts1和struts2的区别struts1和struts2的区别struts1和struts2的区别struts1和struts2的区别...
struts.properties设置( struts.objectFactory = ... <filter-name>struts-cleanup org.apache.struts2.dispatcher.ActionContextCleanUp <filter-name>struts-cleanup <url-pattern>/* </filter-mapping>
struts例子struts例子struts例子struts例子struts例子struts例子struts例子struts例子struts例子struts例子struts例子struts例子struts例子struts例子struts例子
struts包struts包struts包struts包struts包struts包struts包struts包
<filter-name>struts-cleanup</filter-name> <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class> filter> <filter> <filter-name>sitemesh</filter-name> <filter-class>...
struts上传struts上传 struts上传struts上传
struts练习struts练习struts练习
一个很好的关于Struts2的讲义!struts2讲义struts2讲义struts2讲义struts2讲义struts2讲义struts2讲义
struts源码struts源码struts源码struts源码
struts 翻译struts 翻译struts 翻译struts 翻译struts 翻译
Struts2是一套非常优秀的Java WEB应用框架,实现优雅、功能强大、使用简洁。目前已有大量的企业项目采用Struts2来作为Web框架进行开发,掌握Struts2是每个进行Web开发的Java程序员的一项必备技能。 本视频对Struts2...
struts2-core-2.0.1.jar, struts2-core-2.0.11.1.jar, struts2-core-2.0.11.2.jar, struts2-core-2.0.11.jar, struts2-core-2.0.12.jar, struts2-core-2.0.14.jar, struts2-core-2.0.5.jar, struts2-core-2.0.6.jar,...
配置Struts配置Struts配置Struts配置Struts配置Struts配置Struts
struts-config.xml struts标准配置文件 struts-config
Struts简介 什么是Struts Struts基本运作流程 ActionMapping类 Action类 ActionForm类 ActionError与ActionMessage 协同开发 模块化程序 Struts异常处理 Struts国际化支持 PlugIn接口 等等
struts1 struts2 Struts1和Struts2区别
struts2 资料struts2 资料struts2 资料struts2 资料
struts2 总结工程大全struts2 总结工程大全struts2 总结工程大全struts2 总结工程大全struts2 总结工程大全struts2 总结工程大全struts2 总结工程大全struts2 总结工程大全struts2 总结工程大全struts2 总结工程大全...