当form表单中的数据是基本类型的时,直接请求action中的url,一点问题都没有。
但是当form表单总有时间类型的数据时,且对应的controller是用一个java对象来绑定对应form提交的数据时,就会出现问题。无法提交成功。
解决办法:
在对应的controller中新增下面的方法:
@InitBinder public void initBinder(WebDataBinder binder) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); dateFormat.setLenient(false); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); }