在controller加入下面代码
@InitBinder
public void bindingPreparation(WebDataBinder binder) {
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
CustomDateEditor orderDateEditor = new CustomDateEditor(dateFormat, true);
binder.registerCustomEditor(Date.class, orderDateEditor);
}
本文介绍如何在Spring MVC Controller中使用@InitBinder注解和CustomDateEditor类来实现自定义日期格式的输入验证和转换。
598





