springboot中@PostMapping常用说明
PostMapping属性
name
value
请求路由地址path
指定路由地址params
指定request中必须包含某些参数值headers
指定request中必须包含某些指定的header值consumes
请求提交内容类型,MediaType方式,如application/json
、application/x-www-urlencode
、multipart/form-data
等produces
请求返回的数据类型,仅当request请求头中的(Accept)类型中包含该指定类型才返回,如application/json
片段代码
@PostMapping(value = "/admin", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Object> postPCWithJson(@RequestBody Object body,HttpServletRequest request, HttpServletResponse response, HttpMethod httpMethod) throws URISyntaxException {
// TODO
return new ResponseEntity("", HttpStatus.OK);
}