Detailed description of how to use Spring mvc ant path, mvcant

Source: Internet
Author: User

Detailed description of how to use Spring mvc ant path, mvcant

How to Use Spring mvc ant path

Summary:

All WEB applications need to resolve the ing between URLs and request processors. spring MVC is the same, but Spring MVC is just like everything Spring has done (flexible and configurable, but it also causes a lot of complexity), there is certainly not only one way to map the relationship between the URL and the Controller, and in fact, you can create your own ing rules and implementations, not only depends on URL ing.

1. Spring path match

Path Matching in Spring MVC is much more flexible than standard web. xml. The default policy implements org. springframework. util. as the name suggests, the path mode uses the Apache Ant style path. The Apache Ant style path has three wildcard matching methods (listed in the following table) these can be combined into many flexible path modes.

2. Apache ant type

The following describes the matching rules of apache ant, which is quite simple.

Ant wildcard description

Wildcard Description
? Match any single character
* Matches 0 or any number of characters
** Match 0 or more Directories

3. Example:

1./views/products/**/*. cfm

# Matches/views/products/index.cfm/views/products/SE10/index.cfm/views/products/SE10/details.cfm/views/products/ST80/index.cfm/views/products/ST80/details.cfm# Does Not Match:/views/index.cfm/views/aboutUs/index.cfm/views/aboutUs/managementTeam.cfm

2./views/**/*. cfm

# Matches:/views/index.cfm/views/aboutUs/index.cfm/views/aboutUs/managementTeam.cfm/views/products/index.cfm/views/products/SE10/index.cfm/views/products/SE10/details.cfm/views/products/ST80/index.cfm/views/products/ST80/details.cfm# Does Not Match:/views/index.htm/views/readme.txt

3./views/index ??. Cfm

# Matches:/views/index01.cfm/views/index02.cfm/views/indexAA.cfm# Does Not Match:/views/index01.htm/views/index1.cfm/views/indexA.cfm/views/indexOther.cfm/views/anotherDir/index01.cfm

If we know this, we can flexibly configure url ing in Spring MVC.

If you have any questions, please leave a message or go to the community on this site for discussion. Thank you for reading this article. Thank you for your support!

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.