因为使用了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方法,加入为空判断处理。
- @Override
- public void findStaticResource(String path, HttpServletRequest request,
- HttpServletResponse response) throws IOException {
- // 用于解决调试重新加载静态资源文件时产生的pathPrefixed为null的NullPointException异常
- if (pathPrefixes == null) {
- pathPrefixes = parse(getAdditionalPackages());
- }
- super.findStaticResource(path, request, response);
- }
3、问题本质和解决办法:缺少xstream.jar
下载地址:http://pan.baidu.com/s/1kTJuHmv