No mapping found for HTTP request with URI

Source: Internet
Author: User

The new study Spring3.0,angularjs and Bootstrap, has been considering if the three together. Today, in the process of trying, encountered a stumbling block.No mapping found for HTTP request with URI [/springmvc/js/bootstrap.min.js]

The configuration of Web. XML is as follows

<servlet-mapping> 
<servlet-name>Mumu</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

Here, there are three ways to configure it.

    • exactly matches the
<url-pattern>/</url-pattern>

Will match a path-type URL such as/login, which does not match a suffix url such as *.jsp, thus causing static resources such as js,css to be inaccessible to

    • Path matching
<url-pattern>/*</url-pattern>

Matches all URLs: path-and suffix-type URLs (including/login,.jsp,.js and *.html, etc.)
When the URL matches,
<url-pattern>/</url-pattern>does not match to *.jsp, does not enter spring's Dispatcherservlet class
<url-pattern>/*</url-pattern>Will match *.jsp, resulting in spring's Dispatcherservlet class, and then to find the controller, and then can not find the corresponding controller so error.

    • Name extension matches
<url-pattern>*. Do</url-pattern> 
<url-pattern>*. html</url-pattern>Requests that match the end of all HTML
<url-pattern>*</url-pattern>Can't use*, or error

Workaround:

    • The first method: Add 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>
    • The second method: Add the following in the servlet
<mvc: Default -servlet-handler />  

Note: The required version is spring3.0.5 or higher.

    • The third method: Add the following in the servlet
mapping="/resources/**"location="/resources/" />

This configuration tells spring how to handle static resources.

No mapping found for HTTP request with URI

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.