ConversionFailedException: Failed to convert from type String to type Date for value ‘ ‘;日期格式转换异常

1.属性上使用注解@DateTimeFormat  @JsonFormat

1.在多条件分页查询的时候,如果日期是空的,在映射到实体类日期属性的时候就会出问题,显示类型不匹配,需要在日期属性上添加注解,即使是空内容也要转成这个pattern格式。

@DateTimeFormat(pattern = "yyyy-MM-dd")

 

 另外,Team中也有时间属性createTime,前后台传输的时候就需要格式化日期。后台查询的日期是一串数字或美式时间,需要使用注解转换,还有改时区。

@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")

2.方法上使用注解@InitBinder

3.刷新cache和cookie

日期转换没问题,页面还是没有加载数据,刷新浏览器缓存和cookie会话,在这个区域右键。

猜你喜欢

转载自blog.csdn.net/qq_40454863/article/details/119738421