The Spring MVC framework maps the methods of @requestmapping in a class with @controller by scanning and then calls the mapped method to process the request, which is handled by the Dispaterservlet by default.
HTTP request Mapping principle
the basis for which Spring MVC maps
URL-qualified: URL expression
Spring MVC's address mapping supports standard URLs, while default support is Ant-style URLs. Gca
URL |
Description |
/account/*/create |
Match URLs such as/account/aaa/create,/account/bbb/create, etc. |
/account/**/create |
Match URLs such as/account/create,/account/aaa/bbb/create, etc. |
/account/create?? |
Match URLs such as/ACCOUNT/CREATEAA,/account/createbb, etc. |
/account/{accountid} |
Match URLs such as account/123, ACCOUNT/ABC, etc. |
/account/**/{userid} |
Match URLs such as account/aaa/bbb/123, account/aaa/456, etc. |
Account/{accountid}/customer/{customerid}/detail |
URLs that match account/1234/customer/0000/detail, etc. |
URL-qualified: The value of {XXX} in the binding path
@RequestMapping ("/{accountid}") public Modelandview showdetail (@PathVariable ("AccountId" String accountId) { modelandview mavnew Modelandview (); Mav.setviewname ("User/showdetail"); Mav.addobject ("user", Userservice.getuserbyid (userId)); return Mav;}
The {XXX} placeholder in the URL can be bound to the entry of an action method by @pathvariable ("xxx").
In the 3. X if @pathvariable does not specify a parameter name, it is only possible to open the debug switch (javac-debug=no) at compile time!! (not recommended), it seems that 4.x does not have this problem.
Spring MVC HTTP Request address Mapping (iii)