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

使用Spring MVC3框架时,可能会遇到这个问题,请求后台没有任何响应,页面显示

The request sent by the client was syntactically incorrect 说的意思是:由客户端发送的请求是语法上是不正确的

把spring日志级别调整到debug级别(log4j.logger.org.springframework=DEBUG),终于找出原因了:

Field error in object 'ad' on field 'beginDate': rejected value [2015-6-24 15:50:14]; codes [typeMismatch.ad.beginDate,typeMismatch.beginDate,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [ad.beginDate,beginDate]; arguments []; default message [beginDate]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'beginDate'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type @javax.persistence.Column java.util.Date for value '2015-6-24 15:50:14'; nested exception is java.lang.IllegalArgumentException]

说是日期转换错误,bean里用的是date类型,jsp用的input,string类型


解决办法:在bean的getBeginDate方法上加注解:

如果传入的值是yyyy-MM-dd HH:ss:mm类型的,就加@DateTimeFormat(pattern = "yyyy-MM-dd HH:ss:mm")

如果传入的值是yyyy-MM-dd类型的,就加@DateTimeFormat即可


之前解决过,这次又遇到忘记了,写下来作为记录。


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值