http://blog.csdn.net/chenleixing/article/details/45190371
方法一:实体类中加日期格式化注解
- @DateTimeFormat(pattern = "yyyy-MM-dd")
- private Date receiveAppTime;
如上,在对应的属性上,加上指定日期格式的注解,本人亲自测试过,轻松解决问题!
方法二:控制器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:不能为空值