前后端传参,出现400错误

1 篇文章 0 订阅

**HTTP 错误 400 
400 请求出错 
由于语法格式有误,服务器无法理解此请求。不作修改,客户程序就无法重复此请求。**

看这个解释,那应该是参数的问题,但是参数检查了一下怎么也没发现到底哪里少参数了

下面这个是前端发送的参数: 
前端发送的参数

下面是后端controller中的接受方法的部分

    @RequestMapping(value = "save/all", method = RequestMethod.GET)
    @ResponseBody
    public JSONObject saveAll(@RequestParam(required = false, value = "id") Integer id,
                              @RequestParam(value = "dishId") Integer dishId,
                              @RequestParam(value = "mainCost") BigDecimal mainCost,
                              @RequestParam(value = "assistCost") BigDecimal assistCost,
                              @RequestParam(value = "deliciousCost") BigDecimal deliciousCost,
                              @RequestParam(value = "ingredientId") List<Integer> ingredientId,
                              @RequestParam(value = "itemType") List<Integer> itemType,
                              @RequestParam(value = "netCount") List<Integer> netCount,
                              @RequestParam(value = "otherCount") List<Integer> otherCount,
                              @RequestParam(value = "isAutoOut") List<Integer> isAutoOut,
                              ServletRequest request) throws SSException {
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

所有的参数都是一 一对应的,最后通过一个一个参数的在地址栏中的传递,找到了罪魁祸首:netCount,otherCount 
这两个参数的类型出错了,传输过来的数值不能使用Integer来接收 
把相应的接收改成

@RequestParam(value = "netCount") List<BigDecimal> netCount,
@RequestParam(value = "otherCount") List<BigDecimal> otherCount,
  • 1
  • 2
  • 3

错误解决!!!以后要记着遇到问题不要盲目的去找问题,有时候可能一个一个的试参数会比漫无边际的寻找更有用!!

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值