sringmvc接收日期参数

 

 

@RequestMapping("toDate.do")
    public String todate(Date date) {
        
    return "login";    
    }



@InitBinder
    public void initBinder(ServletRequestDataBinder binder){
        //只要网页中传来的数据格式为yyyy-MM-dd 就会转化为Date类型
        binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"),
                true));
    }

 

 

@DateTimeFormat(pattern="yyyy-MM-dd")
原文地址:https://www.cnblogs.com/sh-0131/p/11455864.html