首页 > 编程语言 > 详细

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

时间:2017-06-24 19:18:12      阅读:3329      评论:0      收藏:0      [点我收藏+]

页面报错:

技术分享

 

后台错误:

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关于前台日期作为实体类对象参数类型转换错误

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!