spring@Controller注解接受参数的方式

xiaoxiao2021-02-28  127

post请求,

POST请求接受参数,需要加上注解@RequestBody

类型1: 传参为json格式,但是没有实体类可以去接受参数
类型2:用实体类去接受参数
类型1@RequestMapping(value = "/POST/pos/discountinforinqury", method = RequestMethod.POST) public String queryDiscount( @RequestBody String jsonString) throws ExecutionException, InterruptedException JSONObject jsonObject = JSONObject.parseObject(jsonString); String response = queryDiscountInfoService.queryDiscountInfo(jsonObject.getString("card_no"), jsonObject.getBigDecimal("trade_money"),jsonObject.getString("samNo")); return response; 类型2@RequestMapping(value = "/pos/accounttransaction", method = RequestMethod.POST) public JSONObject customerAcctountConsume(@RequestBody ConsumeRequest request)throws Throwable {
转载请注明原文地址: https://www.6miu.com/read-39596.html

最新回复(0)