ajax 提交数据时报400错误

xiaoxiao2021-02-28  18

原因:由于传得参数类型和接收的参数类型不一致导致无法再controller层接收数据。

解决办法:将参数类型修改一致。

如下:

jsp页面:

$.post("${pageContext.request.contextPath}/rep/findRep",                                        {                                            rep1 : any_1                                        },

                                        function(data) {}

});

controller层:

@RequestMapping("findRep")

    public Map findRep(HttpServletRequest request,Integer rep1,Integer page) {}

由于接收的rep1是integer类型,

所以在jsp中传数据  为“qwe”不能被转成int类型所以会包400错误。

解决:

严格限制rep1参数为数字。

转载请注明原文地址: https://www.6miu.com/read-2450332.html

最新回复(0)