@RequestMapping注解作用:为指定的类或方法设置相应URL
value属性
path属性
method属性
类型:RequestMethod[]
public enum RequestMethod { GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE }
作用:为当前URL【类或方法】设置请求方式【POST、DELETE、PUT、GET】
注意:
params
headers
示例代码
@RequestMapping(value = {"/saveEmp","/insertEmp"},
method = RequestMethod.GET,
params = "lastName=lisi",
headers = "User-Agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36")
public String saveEmp(){
System.out.println("添加员工信息!!!!");
return SUCCESS;
}
@RequestMapping(method = RequestMethod.POST) public @interface PostMapping {} @RequestMapping(method = RequestMethod.GET) public @interface GetMapping {} @RequestMapping(method = RequestMethod.PUT) public @interface PutMapping {} @RequestMapping(method = RequestMethod.DELETE) public @interface DeleteMapping {}