报错com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type java.util.Date from String 2020-08-09
问题所在
1.服务器用@RequestBody接收数据,前端传的格式是yyyy-MM-dd。
2.异常描述:反序列化失败,yyyy-MM-dd不是有效的格式。
解决方案
@ApiModelProperty(value = "添加时间")
@JsonFormat(pattern="yyyy-MM-dd")
private Date addTime;
在Entity类中添加了@JsonFormat