Spring Mvc使用Jackson進(jìn)行json轉(zhuǎn)對(duì)象時(shí)跟压,遇到的字符串轉(zhuǎn)日期的異常處理(Can not deserialize value of type Date from String)
參考鏈接:https://blog.csdn.net/qq906627950/article/details/79503801
親測(cè)有效方案:
public class JasonDateParamDTO {
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")//這個(gè)注解是返回給前端的
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")//這個(gè)是接受前端的
private Date startDate;
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
}