
The request sent by the client was syntactically incorrect 说的意思是:由客户端发送的请求是语法上是不正确的。但还是不明白哪里出了问题,
我的URL:http://localhost:8080/memo/test/school/insertKlass.html ,真看不出那个参数出错了,实在没办法我把spring日志级别调整到debug级别,终于找出原因了:
[20131017 20:42:31.218-DEBUG] Resolving exception from handler [com.memo.test.school.handler.KlassHandler@3ca41c]: org.spring.framework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'klass' on field 'grade': rejected value [DD]; codes [typeMismatch.klass.grade,typeMismatch.grade,typeMismatch.java.lang.Integer,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes
[klass.grade,grade]; arguments []; default message [grade]]; default message [Failed to convert property value of type 'java
.lang.String' to required type 'java.lang.Integer' for property 'grade'; nested exception is java.lang.NumberFormatException:
For input string: "DD"] org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.resolveException(132)
原来,Klass类里的属性grade,我定义的是Integer,但在页面上输入的是字符DD,因此由于参数格式错误,服务器才会报出HTTP 400的错误代码。
我也遇到了类似的问题,也是因为定义属性type是Integer类型,但页面输入的是字符类型的,报错,我在字典中进行了设置,让前台只能选择固定的几个类型,每个类型对应一个数据表中的值,选择对应的值,问题解决。
http://jiaxiaoyuan1204.blog.163.com/blog/static/6555315201391784354670/ 转自