springboot为当前controller重写日期绑定接受前台的日期字符串
仅对当前controller生效,只需在当前controller中写一个方法,
实现前端传日期字符串后端只需Date类型接收
/**
* 重写日期绑定接受前台的日期字符串
*
* @param binder
*/
@InitBinder
public void initBinder(ServletRequestDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}