配置了sitemesh后用struts2标签就报错,用ognl El标签却不报错。
原因:sitemesh的过滤器 com.opensymphony.sitemesh.webapp.SiteMeshFilter 应该在
struts2的过滤器 org.apache.struts2.dispatcher.FilterDispatch
(或org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter)之前,在
org.apache.struts2.dispatcher.ActionContextCleanUp过滤器之后
而且ActionContextCleanUp、FilterDispatch(或StrutsPrepareAndExecuteFilter)这两个struts2的过滤器必须得配置
ActionContextCleanUp:延长action中属性的生命周期,包括自定义属性,以便在jsp页面中进行访问,让actionContextcleanup过滤器来清除属性,不让action自己清除。
为了使用WebWork,我们只需要在web.xml配置FilterDispatcher一个过滤器即可,阅读一下FilterDispatcher的 JavaDoc和源码,我们可以看到它调用了:
finally{
ActionContextCleanUp.cleanUp(req);
}
在ActionContextCleanUp中,有这样的代码:
req.setAttribute(CLEANUP_PRESENT, Boolean.TRUE);
如果FilterDispatcher检测到这个属性,就不会清除ActionContext中的内容了,而由 ActionContextCleanUp后续的代码来清除,保证了一系列的Filter访问正确的ActionContext.
如果用到SiteMesh的Filter或者其他类似Filter,那么设置顺序是:
ActionContextCleanUp filter
SiteMesh filter
FilterDispatcher
分享到:
相关推荐
Struts 2.0提供一个Sitemesh插件,允许在Sitemesh模板中使用Struts标记。 要使用Sitemesh需要包含Freemark,Sitemesh和Sitemesh插件库文件。 配置过滤器 如果需要使用Freemark模板文件作为装饰器文件,需要在web....
struts2-sitemesh-plugin-2.2.1.1.jarstruts2
一个Struts2+Spring2.5+SiteMesh的小DEMO,仅供大家做个参考!我也刚学会。欢迎大家多交流!
struts2-sitemesh-plugin-2.1.6.jar
测试用报表架构(sitemesh+struts2+birt)
struts2-sitemesh-plugin-2.0.8.jar
struts2+sitemesh例子 该例子描述了struts2+sitemesh的配置,比较实用
SiteMesh 开发jar包 Struts2 SiteMesh 插件 jar包
struts2-sitemesh_入门收集struts2-sitemesh_入门收集
NULL 博文链接:https://takeme.iteye.com/blog/1716488
3.1 使用web.xml配置Struts2实现Web项目Struts2应用 37 3.2 使用配置文件struts.xml实现页面导航定义 38 3.3 使用Action类控制导航业务数据 40 3.4 使用ActionSupport进行校验 42 第4章 另一Struts2核心技术:拦截器...
sitemesh+ spring2 + struts2 + hibernate 的 demo
struts2与sitemesh整合所需的两个最新架包sitemesh-2.4.2,struts2-sitemesh-plugin-2.1.8
Sitemesh 3 的使用及配置
struts2sitemesh-freemarker 源码
包含struts2-core-2.5.10.1.jar,struts2-jfreechart-...struts2-sitemesh-plugin-2.5.10.1.jar,struts2-spring-plugin-2.5.10.1.jar,struts2-testng-plugin-2.5.10.1.jarstruts2-tiles-plugin-2.5.10.1.jar等jar包
8.1.1 页面上:如何使用自定义结果组件构建Struts 2 Ajax应用程序 171 8.1.2 实现JSON结果类型 173 8.2 常用的结果类型 180 8.2.1 RequestDispatcher,也叫做dispatcher 180 8.2.2 ServletRedirectResult,也叫做...
struts2-sitemesh-plugin-2.1.8.1.jar
最近温习ssh2整合编程,顺便浏览下struts2有什么更新的消息,下载了新版本的struts2的2.1.8.1版,使用的是MyEclipse8.0开发,但是问题就随之而来了。MyEclipse8.0中自带的struts2版本是2.1.6,spring版本有2.0,2.5...
解决 java.lang.NoSuchFieldException: DEFAULT_PARAM>问题,下载后替换即可。