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功能
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧