运行时异常:
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”)
正文完