restful接口Map接收参数的两种方式(x-www-form-urlencoded方式和JSON)
restful接口Map接收参数的两种方式(x-www-form-urlencoded方式和JSON)
JSON数据格式,但是是用Map来接收的,同对象来接收是一样的。
Map接收参数灵活性,特别是针对需要验签的接口。
DEMO:
@PostMapping("/package/req") public PkgRespVO packageReq(@RequestBody Map<String, Object> request) {}
#1.x-www-form-urlencoded方式
@RequestMapping(value = "/util/encryptByDes", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) @ResponseBody public Map encryptByDes(@RequestParam Map<String,Object> map) throws Exception;
#2.JSON方式
@RequestMapping(value = "/util/encryptByDes") @ResponseBody public Map encryptByDes(@RequestBody Map<String,Object> map) throws Exception;