前端传日期的时候报下面的错误:
Field error in object 'orderInfoVO' on field 'orderTimeEnd': rejected value [2020-11-08 15:34]; codes [typeMismatch.orderInfoVO.orderTimeEnd,typeMismatch.orderTimeEnd,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [orderInfoVO.orderTimeEnd,orderTimeEnd]; arguments []; default message [orderTimeEnd]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'orderTimeEnd'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@org.springframework.format.annotation.DateTimeFormat java.util.Date] for value '2020-11-08 15:34'; nested exception is java.lang.IllegalArgumentException: Invalid format: "2020-11-08 15:34" is too short]
有两个地方需要注意:
1、,将日期加上@DateTimeFormate
2、xml中的判空不能加 ‘’空字符串的判空,只能加!=null的判空