problem BUG:
When using SPRINGMVC to deploy Web projects, we often have problems with 404 of resources not found when accessing static resources. Reason:
This is because Dispatcherservlet can intercept static resources and cause static resources to be inaccessible. Solution: scenario One, set the Defaultservlet in Web. XML, note that this configuration requires Dispatcherservlet interception before it can play an early intercept effect.
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.css</ url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</ servlet-name>
<url-pattern>*.gif</url-pattern>
</servlet-mapping>
< servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.jpg</ url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default </servlet-name>
<url-pattern>*.js</url-pattern>
</servlet-mapping>
< servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.png</ Url-pattern>
</servlet-mapping>
Where default is the name of Tomcat, if the other is the server can check the relevant default servlet name. Scenario Two, configure the resource in the SPRINGMVC configuration file
<mvc:resources mapping= "/images/**" location= "/images/"/>
Where location is the path to the static resource directory, mapping is mapped to resourcehttprequesthandler for processing. scenario Three, configuring the default Servlet processor for static resources in SPRINGMVC (this is the method I use frequently)
<mvc:default-servlet-handler/>
Reference article: http://lzy83925.iteye.com/blog/1186609