让spring mvc controller转换date类型

来源:互联网 发布:linux应用层使用中断 编辑:程序博客网 时间:2024/06/05 22:48

在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);    }
0 0
原创粉丝点击