import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.beans.propertyeditors.CustomDateEditor;
@InitBinder
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
CustomDateEditor dateEditor = new CustomDateEditor(fmt, true);
binder.registerCustomEditor(Date.class, dateEditor);
}
本文介绍如何在 Spring MVC 中使用 @InitBinder 注解来自定义日期格式编辑器,通过注册 CustomDateEditor 来实现对 HttpServletRequest 中日期参数的正确解析。
2002

被折叠的 条评论
为什么被折叠?



