Spring MVC "The request sent by the client was syntactically incorrect "解决办法

来源:互联网 发布:js中indexof的用法 编辑:程序博客网 时间:2024/05/21 22:42
使用Spring MVC3框架时,可能会遇到这个问题,请求后台没有任何响应,页面显示如下:
Spring MVC The request sent by the client was syntactically incorrect 解决办法 - AnkerJia - 非专业IT人士
 让人很莫名其妙。

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的错误代码。

0 0
原创粉丝点击