And establish a WEB-INF same level of resources files, stored inside css, js, img resource files.
1, arranged to modify the web.xml
Locate the following configuration items in web.xml
Join
<servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.css</url-pattern> <url-pattern>*.js</url-pattern> <url-pattern>*.gif</url-pattern> <url-pattern>*.png</url-pattern> <url-pattern>*.jpg</url-pattern> </servlet-mapping>
Solve ~
Method 2, spring-mvc.xml configuration
Add the following arranged in a spring-mvc.xml <beans> tag
<!-- 引入静态资源 --> <mvc:annotation-driven /> <mvc:resources mapping="/css/**" location="/resouces/css/**" /> <mvc:resources mapping="/img/**" location="/resouces/img/**" /> <mvc:resources mapping="/js/**" location="/resouces/js/**" />
Method 3, pages cited
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}css/1.css">