首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Struts热加载报错:findStaticResource步骤的NullPointException

2012-06-28 
Struts热加载报错:findStaticResource方法的NullPointException因为使用了struts2的静态内容加载的特性(ht

Struts热加载报错:findStaticResource方法的NullPointException

因为使用了struts2的静态内容加载的特性(http://struts.apache.org/2.2.3/docs/static-content.html)导致了该问题。

?

解决方案[对2.3.3以下版本有效,2.3.4版本同样出现异常,但异常位置已不在这里]:

1. 自定义StaticContentLoader覆盖默认的DefaultStaticContentLoader,并修改struts配置文件指定使用新的StaticContentLoader实现类。

?

<!-- 覆盖静态资源加载类 --><constant name="struts.staticContentLoader" value="coo.struts.config.GenericStaticContentLoader" />

?

2. 覆盖DefaultStaticContentLoader的findStaticResource方法,加入为空判断处理。

?

@Overridepublic void findStaticResource(String path, HttpServletRequest request,HttpServletResponse response) throws IOException {// 用于解决调试重新加载静态资源文件时产生的pathPrefixed为null的NullPointException异常if (pathPrefixes == null) {pathPrefixes = parse(getAdditionalPackages());}super.findStaticResource(path, request, response);}
?

?

热点排行