1. Requestmapping
Requestmapping have class-level and method-level two levels, which contain properties that are value,method,consumes,produces
Value indicates the URL address to respond to.
Method that represents the response request
2.Uri Template
When commenting on requestmapping, you can set its value to correspond to the requested address to be processed. Here you can use a URI template to make the method respond to the request address of the template.
2.1 URI Template variable:
For example:/user/{userid},userid is a variable.
Parameters in the method in which they are mapped can get the value of the parameter with @pathvariable
@RequestMapping ("/user/zhangsan")
public void GetUserId (@RequestMapping String userid)
{
The parameter Useridd value is Zhangsan.
}
2.2 Using regular expressions in URI template variables
@RequestMapping ("/user/{userid:^lkj\\d\\d}")//kk request processing method only handles the UserID's value matching "lkj\\d\\d" request
public void KK (@PathVariable user)
The requestmapping of Spring MVC