问题描述:
org.springframework.validation.BindException:org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'SysUser' on field 'startTime': rejected value [2020-01-01 00:00:00.0]; codes [typeMismatch.SysUser.startTime,typeMismatch.startTime,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [SysUser.startTime,startTime]; arguments []; default message [startTime]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'startTime';
nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [java.util.Date] for value '2020-01-01 00:00:00.0';
问题分析:
1、接口参数的类型是Date,而请求体类型却是String,由于没有指定日期格式,导致装配失败。
解决办法