principle Brief
In the background, the full URL is matched, trimmed, removed <url-pattern> specified context part, remainder URL ', and then annotated @ by the SPRINGMVC response to the request initiated by the front-end. Requestmapping go to the Controller specific method and perform the specific processing.
give me a chestnut .
Full URL of the front-end request:
Http://localhost:8088/aaa/bbb/ccc?myParam=myValue
The URL format specified by the servlet:
<url-pattern>/aaa/*</url-pattern>
The correct configuration for the @RequestMapping is:
@RequestMapping (value= "/BBB/CCC") public
String demomethodsignature (string myparam) {/*method code*/}
If requestmapping= "/AAA/BBB/CCC", the equivalent full URL is:
Http://localhost:8088/aaa/aaa/bbb/ccc?myParam=myValue
Instead of wishing (forced access will show 404 pages)
Http://localhost:8088/aaa/bbb/ccc?myParam=myValue
It can be seen that the value of the annotation @RequestMapping is the result of the "narrow treatment" after <url-pattern>, and the excluded part
Http://localhost:8088/aaa
= http://localhost:8088 +/aaa
= Request Domain name default root path + <url-pattern> explicitly declared path
Conversely, if the annotation @RequestMapping value is "/x/y/z",<url-pattern> specified as "/aaa/*", the equivalent complete URL to the Controller method is accessed:
http://localhost:8088/aaa/x/y/z
=http://localhost:8088 +/aaa +/x/y/x
= domain name root path + <url-pattern> explicitly declared path + @ Requestmapping value
Reference articles:
1, Spring MVC Url-pattern and @requestmapping mapping small problem: http://blog.csdn.net/fangchao3652/article/details/54693814
2, the servlet url-pattern matching rules detailed description: https://www.cnblogs.com/51kata/p/5152400.html