The request sent by the client was syntactically incorrect.
?
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
蕃薯耀 2015年8月14日 16:26:11 星期五
http://fanshuyao.iteye.com/
?
spring校验出错,但后台没有错误提示,页面显示
?
@RequestMapping(value="/testValidate") public String testValidate(@Valid Student student, Map<String,Object> map, BindingResult bindingResult){ System.out.println("testValidate--"); if(bindingResult.hasErrors()){ return "validate"; } return "success"; }
?
?
?
?
?
?
?
?
type?Status report
?
message
?
description?The request sent by the client was syntactically incorrect.
?
?
?
?
?
?
?
?
?
错误原因:参数顺序
?
?
?
?
public String testValidate(@Valid Student student, Map<String,Object> map,
???BindingResult bindingResult)
?
在这个方法中,@Valid标识需要校验的student和参数bindingResult之间相隔了一个参数map,导致出现上面的错误,但控制台没有报错。
?
?
这种校验方式是有一个约定的,就是BindingResult必须紧随@valid之后。
?把中间的那个参数去掉程序就正常了。
?
?
?
?
?
?
?
?
?
?
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
?
蕃薯耀 2015年8月14日 16:26:11 星期五
http://fanshuyao.iteye.com/
?
?
?
?
The request sent by the client was syntactically incorrect
原文:http://fanshuyao.iteye.com/blog/2235560