@RequestParam
参数:HTTP请求体或请求url的QueryString
传参格式:form-data/x-wwww-form-urlencoded
安全性:低
示例代码:
@GetMapping("/queryDetail")
public Response queryDetail(@RequestParam Long id) {
return Response.createSuccess(id);
}
@RequestBody
参数:HTTP请求体
传参格式:application/json、application/xml
安全性:高
@RequestBody可以将body里面所有的json数据传到后端,后端再进行解析成实体类或者List/Map
示例代码:
@RequestMapping(value = "/something", method = RequestMethod.PUT)
public void handle(@RequestBody String body, Writer writer) throws IOException {
writer.write(body);
}
@PathVariable
参数:HTTP请求体或请求url的QueryString
传参格式:form-data/x-wwww-form-urlencoded
安全性:低
示例代码:
@Description("嘻嘻嘻谢谢")
@GetMapping("/queryDetail")
@Authority(RoleEnum.ORG_ADMIN)
public Response queryDetail(@PathVariable Long id) {
Store store=storeService.query(id);
StoreVo detailVo=new StoreVo();
BeanUtils.copyProperties(store, detailVo);
detailVo.setImageList(storeImageService.queryList(Util.getSimpleMap(
new KeyValue("storeId",id)
)));
return Response.createSuccess(detailVo);
}