If your DispatcherServlet intercepts a URL such as *. do, there will be no access to static resources.
If your DispatcherServlet intercepts all "/" requests, the access to *. js, *. jpg will also be blocked.
When developing spring MVC, we will introduce js, img, css and other files on the jsp page.
Most people store these categories under the folder created under the WebRoot file.
In addition, all requests are intercepted in the web. xml file. In this way, the page cannot access files in the js, img, and css folders.
Method 1: Configure defaservlet servlet in web. xml to process static files
<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>*.css</url-pattern></servlet-mapping>
Method 2: Use mvc: resources in Springmvc
Springmvc's <mvc: resources location = "**" mapping = "**"/> label appears in spring3.0.4 and is mainly used to access static resources.
<! -- Access static resource files --> <mvc: resources location = "/js/" mapping = "/js/**"/> <mvc: resources location = "/img/" mapping = "/img/**"/>
Location specifies the location of the static resource
Method 3: Use <mvc: default-servlet-handler/>
<mvc:default-servlet-handler/>
Finally, let's talk about how your DispatcherServlet intercepts URLs such as *. do.
Source code download: http://download.csdn.net/detail/itmyhome/7359943
Welcome to the JAVA technology exchange group: 74955800