SPRINGMVC servlet blocking Mode __springmvc

Source: Internet
Author: User
1, blocking the fixed suffix of the URL, such as set to *.do, *.action, for example:/user/add.action This method is the simplest, will not cause static resources (JPG,JS,CSS) to be intercepted.

2, intercept all, set to/, for example:/user/add/user/add.action

This approach allows you to implement restful URLs, which are used in many types of Internet applications.

However, this method causes the static file (JPG,JS,CSS) to be blocked and not displayed properly. Special handling is required.

mappings for static resource access for example: <mvc:resources location= "/resource/" mapping= "/resource/**"/>

Do not configure the processing of static resources, do the following configuration to resolve the problem of static resources:

    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>/static/* </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>
If possible, SPRINGMVC it is best not to intercept static resources, preferably let the Tomcat container handle itself.

3, intercept all, set to/*,<url-pattern>/*</url-pattern> if this setting is problematic because the request to the action, when the action is transferred to the JSP is intercepted again, Hint cannot mapping success based on JSP path.

In fact, you can also use the <url-pattern>/app/* </url-pattern> configuration.

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.