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

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

我也遇到了类似的问题,也是因为定义属性type是Integer类型,但页面输入的是字符类型的,报错,我在字典中进行了设置,让前台只能选择固定的几个类型,每个类型对应一个数据表中的值,选择对应的值,问题解决。

http://jiaxiaoyuan1204.blog.163.com/blog/static/6555315201391784354670/  转自

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值