問題原因,前臺表單提交到了Date格式的數據,後臺編碼時不能識別該日期格式,故而無法進入到Controller就被攔截!
解決方法,在需要進行轉換的Controller層加入如下代碼,進行初始化轉換。
/*
* 表單提交日期綁定
*/
@InitBinder
public void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setLenient(false);
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}
此時就可以獲取到前臺傳來的日期類型的數據了。