How your Dispatcherservlet intercepts "*.do" such as a URL with a suffix, there is no problem of access to static resources.
If your dispatcherservlet intercepts "/", in order to implement the rest style, all requests are intercepted, and access to static files such as *.js,*.jpg is intercepted.
First, I do the project is to use HTML to jump, due to the code cleanliness, try to use pure Ajax and HTML as interactive display page, with SPRINGMVC do the background processing program.
Scenario One : Activate Tomcat's defaultservlet to handle static files
Need to be configured in Web. xml
<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>
Scenario Two : only the. do file is blocked
<servlet-mapping><servlet-name>mvc-dispatcher</servlet-name><url-pattern>/.do</ Url-pattern></servlet-mapping>
Scenario three : Use Mvc:resources. Location refers to the path under Webroot. Mapping refers to the mappings to be processed.
<mvc:resources location= "/pages/"
Note Header file
<beans xmlns= "Http://www.springframework.org/schema/beans" xmlns:context= "http://www.springframework.org/ Schema/context "xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance "xmlns:mvc=" http://www.springframework.org/ Schema/mvc " xsi:schemalocation=" Http://www.springframework.org/schema/beans/ http Www.springframework.org/schema/beans/spring-beans-3.0.xsd Http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/ SCHEMA/MVC http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd ">
Springmvc How to access static files, such as Jpg,js,css