http://blog.csdn.net/chenleixing/article/details/45190371測試
方法一:實體類中加日期格式化註解
- @DateTimeFormat(pattern = "yyyy-MM-dd")
- private Date receiveAppTime;
如上,在對應的屬性上,加上指定日期格式的註解,本人親自測試過,輕鬆解決問題!spa
方法二:控制器Action中加入一段數據綁定代碼
- @InitBinder
- public void initBinder(WebDataBinder binder) {
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
- dateFormat.setLenient(false);
- binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); //true:容許輸入空值,false:不能爲空值