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));
}