Using restful style writing in the SPRINGMVC project, you need to configure full interception to Web. Xml.
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
However, static resources such as IMAGE,JS,CSS do not want to intercept the project. There are three ways to configure it:
I. Web. XML filtering
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.css</url-pattern>
</servlet-mapping>
But this needs to be configured for each type, cumbersome and easy to miss. To be straightforward, spring provides two ways to handle it. You need to include the MVC tag in the spring configuration file
Xmlns:mvc= "Http://www.springframework.org/schema/mvc"
Xsi:schemalocation= "
Http://www.springframework.org/schema/mvc
Http://www.springframework.org/schema/mvc/spring-mvc.xsd "
Second, the use of mvc:resources.
<mvc:resources location= "/style/" mapping= "/style/**"/>
Third, use the default servlet to respond to static files <mvc:default-servlet-handler/>
Spring requests a static resource file