springmvc-时间类型转换器

 

springmvc 没有默认实现时间类型的转化,需要如下代码实现此功能。

@InitBinder
public void initBinder(HttpServletRequest request,ServletRequestDataBinder binder) throws Exception {
binder.registerCustomEditor(
Date.class,
new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"),true));
}

posted @ 2017-01-09 22:04  wlhebut  阅读(132)  评论(0编辑  收藏  举报