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!