解决springmvc出现HTTP Status 400 -description The request sent by the client was syntactically incorrect

刺骨的言语ヽ痛彻心扉 2022-05-18 06:04 250阅读 0赞

操作工具eclipse:

服务器tomcat;

运行项目ssm,在做一个插入操作时报以下错误

HTTP Status 400 -


type Status report

message

description The request sent by the client was syntactically incorrect.

错误分析:意思是springmvc后台接收参数不能进行绑定

经过排查:发现我后台接收参数的封装类的一个属性是Integer类型,而前端页面传过来的值是字符串,所以就会报这种错误。

比如这样:

  1. 后端pojo
  2. public class CustomSpace {
  3. private Integer cs_id;
  4. private Integer cstmid;
  5. private Integer ps_id;
  6. private Integer w_id;
  7. }
  8. 控制器接收参数:
  9. @RequestMapping("/add")
  10. public String add(HttpServletRequest req,CustomSpace cs) {
  11. return null;
  12. }
  13. 前端页面传回来的值:
  14. <tr><td>登记人员</td><td><input name="w_id" value="${sessionScope.user.w_name }"/></td></tr>

我的座右铭:不会,我可以学;落后,我可以追赶;跌倒,我可以站起来;我一定行。

发表评论

表情:
评论列表 (有 0 条评论,250人围观)

还没有评论,来说两句吧...

相关阅读