电脑上按Ctrl + D,下次访问更方便
服务分类

spring boot运行时异常’java.util.Date’ for property ***

运行时异常:

org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'staffInfo' on field 'birthday': rejected value [1958-01-01]; codes [typeMismatch.staffInfo.birthday,typeMismatch.birthday,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [staffInfo.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 [@io.swagger.annotations.ApiModelProperty @com.baomidou.mybatisplus.annotations.TableField java.util.Date] for value '1958-01-01'; nested exception is java.lang.IllegalArgumentException]
	at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:157)

主要是时间格式问题。解决办法:在实体类的日期字段上加注解@DateTimeFormat(pattern = “yyyy-MM-dd”)

spring boot运行时异常'java.util.Date' for property ***

发表回复

登录后才能评论
联系我们

联系我们

微信客服:

fuwu360微信客服

工作时间:周一至周五,9:30-18:30,节假日休息

返回顶部