您的位置:首页 > 编程语言 > Java开发

spring mvc处理提交的时间类型的参数

2015-02-25 15:52 399 查看
一、只需要在controlller类中加入

[java] view
plaincopyprint?





@InitBinder  

protected  void initBinder(WebDataBinder binder) {  

    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");  

    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));  

}  

方法就可以

二、注解方式:   

[java] view
plaincopyprint?




@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")  //取日期时使用  

@DateTimeFormat(pattern = "yyyy-MM-dd")//存日期时使用  

private Date startTime;
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: