SpringMVC---400错误The request sent by the client was syntactically incorrect ()
2013-07-02 18:02
453 查看
SpringMVC报错信息为The request sent by the client was syntactically incorrect ()
在数据绑定的时候一定要主意Controller方法中的参数名和jsp页面里的参数名字是否一致或者按照绑定的规范来写,如果不一致,可能回报如下错误: Therequest sent by the client was syntactically incorrect ().
从字面上理解是:客户端发送的请求语法错误。实际就是springmvc无法实现数据绑定。
随便举个例子说明:
<sf:form method="post" commandName="person"> name:<sf:input path="name"/><sf:errors path="name"/><br /> pass:<sf:input path="pass"/><sf:errors path="pass" /><br /> age:<sf:input path="age"/><br /> email:<sf:input path="email"/><br /> <input type="submit" value="修改用户" /> </sf:form>
@RequestMapping(value="/{name}/update" , method=RequestMethod.POST) public String update(@PathVariable String name1 ,Person person , BindingResult br) { System.out.println("..."); if(br.hasErrors()) return "/update"; persons.put(name1,person); return "redirect:/listPersonInfo"; }
我表单中的path是name,而在Controller的update方法中却为name1.
而我犯的错误是:
我在表单提交页面加的校验 ,而在 Controller的update方法中 校验对象前没有加@Validated,所以也会报这个错误。
所以Controller修改后应为:
@RequestMapping(value="/{name}/update" , method=RequestMethod.POST) public String update(@PathVariable String name ,@Validated Person person , BindingResult br) { System.out.println("..."); if(br.hasErrors()) return "/update"; persons.put(name1,person); return "redirect:/listPersonInfo"; }
相关文章推荐
- SpringMVC---400错误The request sent by the client was syntactically incorrect ()
- 服务器,tomcat,网页请求错误400,The request sent by the client was syntactically incorrect的问题
- SpringMVC 表单提交参数不匹配报错 提交表单报400错:description The request sent by the client was syntactically incorrect.
- http 400错误 描述:The request sent by the client was syntactically incorrect
- 错误400-The request sent by the client was syntactically incorrect
- springMVC报出400,The request sent by the client was syntactically incorrect.
- javaweb项目错误400-The request sent by the client was syntactically incorrect.
- 错误400-The request sent by the client was syntactically incorrect
- 解决SpringMVC入参出现The request sent by the client was syntactically incorrect请求语法错误方法
- velocity http请求400错误HTTP Status 400 The request sent by the client was syntactically incorrect
- The request sent by the client was syntactically incorrect 服务器,tomcat,网页请求错误400,
- 错误400 The request sent by the client was syntactically incorrect ()的解决
- 前端到后端------HTTP Status 400 ( The request sent by the client was syntactically incorrect)
- Springmvc注解开发:日期类型参数封装报错:The request sent by the client was syntactically incorrect.
- spring mvc 数据绑定问题 提交表单提示HTTP status 400, The request sent by the client was syntactically incorrect
- spring mvc 数据绑定问题 提交表单提示HTTP status 400, The request sent by the client was syntactically incorrect
- 错误The request sent by the client was syntactically incorrect ()的解决
- SpringMVC 出现"The request sent by the client was syntactically incorrect ()"解决办法
- Spring MVC 错误The request sent by the client was syntactically incorrect ()的解决
- springmvc报错:The request sent by the client was syntactically incorrect