Issue: A similar warning occurs when a program is loaded or accessed using a SPRINGMVC deployment project, 2011-01-19 10:52:51,646 WARN [org.springframework.web.servlet.PageNotFound ]-<no mapping found for HTTP request with URI [/sanddemo001/images/1.jpg] in Dispatcherservlet with Name ' Spring '; Mainly look at the inner part of the angle brackets.
Problem reason: The culprit is the configuration of the Dispatcherservlet request URL mapping for spring under Web. XML, which is configured as follows:
<servlet><servlet-name>spring</servlet-name><servlet-class> org.springframework.web.servlet.dispatcherservlet</servlet-class><load-on-startup>1</ load-on-startup></servlet><servlet-mapping><servlet-name>spring</servlet-name>< Url-pattern>/</url-pattern></servlet-mapping>
Analysis Reason:
<servlet-mapping> <url-pattern>/</url-pattern> put all the requests to spring to deal with, And all available request URLs are configured in Constroller with annotations like @requestmapping (value = "/login/{user}", method = Requestmethod.get), In this way, access to static resources such as Js/css/jpg/gif will not be available.
Workaround:
Scenario One: Activate Tomcat's defaultservlet to handle static files add the following configuration in Web. xml
<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>
To configure multiple, each file configuration one to write in front of the Dispatcherservlet, let Defaultservlet first intercept, this will not enter spring, I think performance is the best.
Tomcat, Jetty, JBoss, and GlassFish the name of the default servlet-the name of the default servlet for the "default" Google App Engine-the "_ah_default" Resin default Ser Vlet's name--"Resin-file" WebLogic default servlet name--"Fileservlet" WebSphere default servlet name--"Simplefileservlet"
Workaround 2: Add the following line to the spring configuration file:
<mvc:default-servlet-handler/>
Note that the required version is spring3.0.5 or higher
Workaround 3
<mvc:resources mapping= "/images/**" location= "/images/" cache-period= "31556926"/><mvc:resources mapping= " /js/** "location="/js/"cache-period=" 31556926 "/> <mvc:resources mapping="/css/** "location="/css/" cache-period= "31556926"/>
This configuration tells spring how static resources are handled
Other Links: http://bbs.landingbj.com/t-0-296791-1.html
SPRINGMVC deployment Project static resource file access issues