Rest风格支持使用HTTP请求方式动词来表示对资源的操作
@RequestMapping(value = "/user",method = RequestMethod.GET)
public String getUser(){
return "getUser";
}
@RequestMapping(value = "/user",method = RequestMethod.POST)
public String saveUser(){
return "saveUser";
}
@RequestMapping(value = "/user",method = RequestMethod.PUT)
public String putUser(){
return "putUser";
}
@RequestMapping(value = "/user",method = RequestMethod.DELETE)
public String deleteUser(){
return "deleteUser";
}
核心Filter:HiddenHttpMethodFilter
用法:
1. 前端表单method设置为post方式,增加隐藏域 _method=put/delete
2. SpringBoot中手动开启:
spring:
mvc:
hiddenmethod:
filter:
enabled: true #开启页面表单的Rest功能