在春天我把我的資源放在web-inf之外的文件夾中。就像這樣:
![enter image description here](https://i.stack.imgur.com/oILdh.png)
的web.xml
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
然後在我的servlet-context.xml中(在web.xml中指定配置文件)文件我排除在被管理的資源目錄調度程序,因此調度程序不會收到帶資源前綴的URL,並嘗試將其路由到適當的控制器。
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
在我的jsp然後我就可以訪問資源正常:
<link rel="stylesheet" type="text/css" href="/skillsmanager-ui/resources/css/reset.css" />
你已經問了同樣的問題,準確,並得到了迴應:你不能把CSS文件的WEB-INF。如果您需要更多幫助,請編輯原始問題,向我們展示您的JSP代碼,並告訴我們所有相關文件在目錄樹中的位置。 –