2016-02-27 127 views
0

我在访问我的静态资源时遇到问题/project/resources/(css|js)/。我能够访问我的css文件夹中的index.css,但没有其他。我试图找到根本原因,改变了正则表达式,并搞砸了一切。现在我无法访问,现在甚至无法访问index.css。请从下面的详细信息 -泽西岛休息时无法访问的静态资源

文件结构 -

webapp 
    |____ resources 
    |  |____ css 
    |  |____ js 
    | 
    |____ WEB-INF 
      |____ jsp 

web.xml中 -

<?xml version="1.0" encoding="UTF-8"?> 
    <!-- This web.xml file is not required when using Servlet 3.0 container, 
see implementation details http://jersey.java.net/nonav/documentation/latest/jax-rs.html --> 
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> 
    <filter> 
     <filter-name>REST Web Application</filter-name> 
     <filter-class>org.glassfish.jersey.servlet.ServletContainer</filter-class> 
    <init-param> 
     <param-name>jersey.config.server.provider.packages</param-name> 
     <param-value>com.restui</param-value> 
    </init-param> 
    <init-param> 
     <param-name>jersey.config.server.mvc.templateBasePath.jsp</param-name> 
     <param-value>/WEB-INF/jsp/</param-value> 
    </init-param> 
    <init-param> 
     <param-name>jersey.config.servlet.filter.staticContentRegex</param-name> 
     <param-value>/(resources/(css|js))|(WEB-INF/jsp)/*.*</param-value> 
    </init-param> 
    <init-param> 
     <param-name>jersey.config.server.provider.classnames</param-name> 
     <param-value>org.glassfish.jersey.server.mvc.jsp.JspMvcFeature</param-value> 
    </init-param> 
    </filter> 
    <filter-mapping> 
     <filter-name>REST Web Application</filter-name> 
     <url-pattern>/*</url-pattern> 
    </filter-mapping> 
</web-app> 

我试图找到网络上的解决方案,但没有什么是有用的。希望得到有用的解决方案。

在此先感谢。

+0

你有没有收到一个404 Not Found错误? – nnunes10

回答

0

如果您使用的是Jersey 2.x,jersey.config.servlet.filter.staticContentRegex属性应该可以工作。

我相信你的静态资源只在资源文件夹上。

试试这个:

<init-param> 
    <param-name>jersey.config.servlet.filter.staticContentRegex</param-name> 
    <param-value>/resources/(css|js)/.*</param-value> 
</init-param> 
+0

谢谢,它的工作。添加更多的正则表达式选项会让应用程序混淆吗?我问,以便我可以避免像以前那样为安全添加冗余的东西.. – RSatpute