手记

使用InitBinder来处理Date类型的参数

@RequestMapping("/date") 

public String date(Date date){
System.out.println(date);
return "hello";
}
@InitBinder
public void initBinder(ServletRequestDataBinder binder){ binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), true));
}

0人推荐
随时随地看视频
慕课网APP

热门评论

请教一下 怎么来访问呢, 我访问的URL是http://localhost:8080/date

输出的是null

http://img.mukewang.com/59a1276a0001ed8513190578.jpg


查看全部评论