http 传参数出现400错误

最近在做项目中的一个模块,一直卡在一块bug一直没有解决,项目一直报400错误,上网百度了一下400错误:

**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

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


原文地址:https://blog.csdn.net/zgrgfr/article/details/53262110

猜你喜欢

转载自blog.csdn.net/xujingcheng123/article/details/80757008