Spring Mvc使用Jackson进行json转对象时,遇到的字符串转日期的异常处理(Can not deserialize value of type Date from String)
参考链接:https://blog.csdn.net/qq906627950/article/details/79503801
亲测有效方案:
public class JasonDateParamDTO {
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")//这个注解是返回给前端的
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")//这个是接受前端的
private Date startDate;
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
}