springmvc中注册时间类型转换器接受Date类型
2015-01-20 20:33
375 查看
<span style="white-space:pre"> </span>@InitBinder public void initBinder(ServletRequestDataBinder binder){ binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), true)); }
注册转换器后,就能在controller里接受时间类型的参数,和带有时间类型的实体,接收类型为yyyy-MM-dd
<span style="white-space:pre"> </span>@RequestMapping("/person1.do") public String toPerson(String name, Integer age, String address, Date birthday) { System.out.println(name+" "+age+" "+birthday ); return "index"; }
相关文章推荐
- SpringMVC 参数绑定获取的CST时间(Java.util.Date)类型问题
- 关于SpringMVC+java+mysql的Date类型的时间问题
- springmvc中前台Date类型直接传到后台需要添加一个时间属性编辑器
- JavaScript中的Date类型-计算时间差
- Java 日期时间 Date类型,long类型,String类型表现形式的转换
- Mysql 时间类型 DATETIME、DATE和TIMESTAMP类型
- 时间与相关类型(2) - TDate、TTime、TTimeStamp
- 时间字符串和date类型转化为时间字符串比较
- hibernate jpa 注解 @Temporal(TemporalType.DATE) 格式化时间日期,页面直接得到格式化类型的值
- 自定义类型转换器(转换器的注册方法)
- hibernate jpa 注解 @Temporal(TemporalType.DATE) 格式化时间日期,页面直接得到格式化类型的值
- java 转换String类型的当前时间为Date类型
- AppFuse中日期时间(Date,Timestamp,Time)类型问题
- JS将字符串类型的时间格式转换为date格式
- Oracle时间类型date,timestamp时间差计算
- jsp中从页面获得String类型时间字符串,存入Oracle中Date类型字段方法
- 第五部份 01 深入JavaScript与.NET Framework中的日期时间 JavaScript中的Date类型
- 深入JavaScript与.NET Framework中的日期时间(3):JavaScript中的Date类型(中)
- Hibernate连接Oracle的Date类型字段丢失时间问题(解决方案)
- jdbc的Date类型处理,解决java.util.date与java.sql.date的时间数据丢失