在controller中增加以下方法
@InitBinder
public void initBinder(ServletRequestDataBinder binder) {SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}
本文介绍如何在Spring MVC中使用@InitBinder注解定制日期格式。通过注册CustomDateEditor实现对传入日期参数的格式控制。
在controller中增加以下方法
@InitBinder
public void initBinder(ServletRequestDataBinder binder) {
1587
1万+

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