http 传参数出现400错误

您所在的位置:网站首页 什么是参数错误 http 传参数出现400错误

http 传参数出现400错误

2024-02-03 19:01| 来源: 网络整理| 查看: 265

最近在做项目中的一个模块,一直卡在一块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 ingredientId, @RequestParam(value = "itemType") List itemType, @RequestParam(value = "netCount") List netCount, @RequestParam(value = "otherCount") List otherCount, @RequestParam(value = "isAutoOut") List isAutoOut, ServletRequest request) throws SSException { 12345678910111213

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

@RequestParam(value = "netCount") List netCount, @RequestParam(value = "otherCount") List otherCount, 123

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

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



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3