码迷,mamicode.com
首页 > 编程语言 > 详细

springmvc关于前台日期作为实体类对象参数类型转换错误

时间:2017-06-24 19:40:59      阅读:927      评论:0      收藏:0      [点我收藏+]

标签:context   前台   页面   illegal   技术   form   span   nested   ror   

页面报错:

技术分享

 

后台错误:

Field error in object ‘user‘ on field ‘birthday‘: rejected value [2013-06-24]; codes [typeMismatch.user.birthday,typeMismatch.birthday,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [user.birthday,birthday]; arguments []; default message [birthday]]; default message [Failed to convert property value of type ‘java.lang.String‘ to required type ‘java.util.Date‘ for property ‘birthday‘; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type java.lang.String to type java.util.Date for value ‘2013-06-24‘; nested exception is java.lang.IllegalArgumentException]

 

解决方案:在对应的实体类属性上加入   @DateTimeFormat(pattern = "yyyy-MM-dd")

技术分享

 

springmvc关于前台日期作为实体类对象参数类型转换错误

标签:context   前台   页面   illegal   技术   form   span   nested   ror   

原文地址:http://www.cnblogs.com/wiseroll/p/7074070.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!