在controller类里,添加这段代码
@InitBinder
public void initBind(WebDataBinder binder){
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
CustomDateEditor dateEditor = new CustomDateEditor(df, true);
binder.registerCustomEditor(Date.class, dateEditor);
}