SpringMVC接收Date类型参数

在Controller中添加一个数据绑定方法:

注:只在当前Controller中生效

@InitBinder
public void initBinder(ServletRequestDataBinder bin){
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    CustomDateEditor cust = new CustomDateEditor(sdf,true);
    bin.registerCustomEditor(Date.class,cust);
}

猜你喜欢

转载自blog.csdn.net/lq1083301982/article/details/84543878