Recently used in the project to Spring3, in the exclamation Spring3 annotation configuration is refreshing at the same time unexpectedly appeared this discordant thing, really unbearable
Issue: A similar warning appears when the program loads or is accessed with a browser after the project is deployed, 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 inside 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 of the cause:<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: 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>
That's OK.
Update: The problem has been re-examined today and a solution has been found.
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
Spring3 Js/css/jpg/gif and other static resources cannot be found (no mapping found for HTTP request with URI) problem resolution