首页 > 其他 > 详细

The request sent by the client was syntactically incorrect

时间:2015-08-15 02:15:31      阅读:277      评论:0      收藏:0      [点我收藏+]

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";
	}

?

?

?

?

?

?

HTTP Status 400 -

?


?

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!