Spring MVC No Mapping found for HTTP request with URI

Source: Internet
Author: User

cause of the problem: 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>

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>

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

<!--Handles HTTP GET requests for/resources/** by efficiently serving up static resources in the ${webapproot}/resour CES directory--

<mvc:resources mapping= "/resources/**" location= "/resources/"/>

This configuration tells spring how static resources are handled


This article is from the "Jodyrex" blog, make sure to keep this source http://503431920.blog.51cto.com/6681280/1642256

Spring MVC No Mapping found for HTTP request with URI

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.