关于找不到类org.apache.struts2.sitemesh.FreemarkerPageFilter
java.lang.ClassNotFoundException: org.apache.struts2.sitemesh.FreemarkerPageFilter
原因:struts-sitemesh-plugin 2.1.8中FreeMarkerPageFilter的失效问题
解决方法:
方法1:升级struts2的版本
Struts 2.2.1修复了之前版本的众多bug,主要修复列举如下:
<s:reset type="image">标签上缺少src属性
Struts2 showcase无法在JBoss 5.1上部署
struts-sitemesh-plugin 2.1.8中FreeMarkerPageFilter的失效问题
XWork FileManager不会解码URL
ConventionUnknownHandler与rest插件的协作问题
StrutsSpringTestCase的内存泄漏问题
css_xhtml主题无法应用在IE8上,在其他浏览器上也无法正常使用
javassist在JBoss 5.1上的问题
Struts 2.2.1的主要改进列举如下:
升级至OGNL 2.7
文件上传:可以对allowedTypes参数设置不同的File Content Type值
完全集成了SiteMesh 2、Freemarker 2.4.2及Velocity 1.3
将xwork核心迁移至Struts 2
将FreeMarker升级至2.3.16
将Velocity引擎升级至1.6.3
方法2:修改原代码
Struts2的sitemesh插件struts2-sitemesh-plugin-2.1.6的一个BUG,是FreeMarkerPageFilter的getLocale方法没有对invocation添加非空判断造成的,解决办法是解压包,然后找到org.apache.struts2.sitemesh.FreeMarkerPageFilter这个类,将
1. protected Locale getLocale(ActionInvocation invocation, Configuration configuration) {
2. if (invocation.getAction() instanceof LocaleProvider) {
3. return ((LocaleProvider) invocation.getAction()).getLocale();
4. } else {
5. return configuration.getLocale();
6. }
7. }
修改为:
1. protected Locale getLocale(ActionInvocation invocation, Configuration configuration) {
2. if (invocation != null && invocation.getAction() instanceof LocaleProvider) {
3. return ((LocaleProvider) invocation.getAction()).getLocale();
4. } else {
5. return configuration.getLocale();
6. }
7. }