The request sent by the client was syntactically incorrect.

HTTP Status 400 -


type Status report

message

description The request sent by the client was syntactically incorrect.


Apache Tomcat/7.0.77

description:由客户端发送的请求是语法上是不正确的

关于这个400-,大部分都是说前端jsp页面的控件名称(name)和controller中接收的参数名称不一致,有这个原因,今天我想记录的是除了这个原因之外还有一个原因就是jsp页面上的某些实体参数标签是不能展示的,因为它根本就没有进到control层

这是我的修改用户信息control

@RequestMapping(value = "/updateUserInfo", method = RequestMethod.POST)
public String updateUserInfo(User user, RedirectAttributes redirectAttributes) {
User newUser = user;
userService.updateUserByUserName(newUser);
redirectAttributes.addAttribute("username", newUser.getUserName());
return "redirect:listUserInfo";
}

jsp页面的userPhone与control层的userPhone不一致,我只能暂时先注释掉userPhone
<%--<tr>--%>
<%--<td class="mdl-data-table__cell--non-numeric">用户电话:</td>--%>
<%--<td>--%>
<%--<div class="mdl-textfield mdl-js-textfield">--%>
<%--&lt;%&ndash;@declare id="userphone"&ndash;%&gt;<input class="mdl-textfield__input" type="text" pattern="-?[0-9]*(\.[0-9]+)?"--%>
<%--name="userPhone"--%>
<%--value="${user.userPhone}">--%>
<%--<label class="mdl-textfield__label" for="userPhone"></label>--%>
<%--</div>--%>
<%--</td>--%>
<%--</tr>--%>
然后问题锁定在userPhone这里,现在就是抓住这个userPhone参数来进行调试,参考了这篇文章:https://cuisuqiang.iteye.com/blog/2054234
然后参考了这篇文章springmvc form表单提交报400错误:https://blog.csdn.net/zlsdmx/article/details/54923422
此文章描述了日期类型和integer类型前台和后台数据库传参报错的问题,举例了日期类型在实体类中的修改方法,但是整数类型的电话号码有所不同,但是我可以把数据库中的电话号码类型换成vachar类型,这样就可以了

综上所述,springmvc form表单提交报400错误不一定是前台表单的参数与control层参数不一致,也有可能是数据库中字段如日期,电话的类型与表单需要的类型不一致,需要在类型方面做修改

 

posted on 2019-04-01 11:14  tlf凌风  阅读(290)  评论(0编辑  收藏  举报