How spring handles static resources

1. <mvc:default-servlet-handler/>default-servlet-handler defines an org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler in the SpringMVC context,

    It will act like an inspector to screen the URLs entering the DispatcherServlet. If it finds that it is a static resource request, it will be transferred to the default Servlet of the Web server; if it is not a static request, it will continue to be processed by the DispatcherServlet; and DefaultServletHttpRequestHandler is the web server that calls Tomcat. It is handled by the default Servlet in .xml.

 

2. The principle is the same as above: Configure <servlet-name>default</servlet-name><url-pattern>*.jpg</url-pattern> in the web.xml of the application

 

3. <mvc:resources ...>

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326771858&siteId=291194637