前端输入框传时间后台解析报错解决

前端传递时间类型的字符串,后台无法解析,报错 Failed to convert from type [java.lang.String] to type [java.util.Date]
在接收时间的controller类加上以下方法即可

包:
import java.util.Date;
@InitBinder
public void initBinder(WebDataBinder binder) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        dateFormat.setLenient(false);
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
    }
原文地址:https://www.cnblogs.com/binghuaZhang/p/13611054.html