spring 日期时间提交出现400错误

来源:互联网 发布:30岁程序员vs公务员 编辑:程序博客网 时间:2024/06/06 06:30

在action 中加入以下代码可以解决问题

    @InitBinder
    public void initBinder(WebDataBinder binder) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        dateFormat.setLenient(false);
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
    }

0 0
原创粉丝点击