当前位置: 代码迷 >> Web前端 >> 运用struts时,文件放到以static或struts开头的文件夹里将不能“正常”访问
  详细解决方案

运用struts时,文件放到以static或struts开头的文件夹里将不能“正常”访问

热度:86   发布时间:2012-08-21 13:00:22.0
使用struts时,文件放到以static或struts开头的文件夹里将不能“正常”访问
起因:在web.xml里配置struts的过滤器后,页面如果正常访问,不是通过action访问,则无法显示

因为:

这是org.apache.struts2.dispatcher包里

DefaultStaticContentLoader类的一个方法
public boolean canHandle(String resourcePath) {
        return serveStatic && (resourcePath.startsWith("/struts") || resourcePath.startsWith("/static"));
    }


所以例如样式等静态文件,及非struts结构的jsp等文件不能放入以static和struts开头的文件夹里
  相关解决方案