@RequestMapping("toDate.do") public String todate(Date date) { return "login"; } @InitBinder public void initBinder(ServletRequestDataBinder binder){ //只要网页中传来的数据格式为yyyy-MM-dd 就会转化为Date类型 binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), true)); }
@DateTimeFormat(pattern="yyyy-MM-dd")