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;