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

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 {       

你可能感兴趣的:(杂类,java)