一则spring中使用PropertyEditors 来注入日期型属性的技巧
2005-03-09 20:25
429 查看
如题。
<bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="java.util.Date">
<bean class="org.springframework.beans.propertyeditors.CustomDateEditor">
<constructor-arg index="0">
<bean class="java.text.SimpleDateFormat">
<constructor-arg><value>yyyy-MM-dd</value></constructor-arg>
</bean>
</constructor-arg>
<constructor-arg index="1"><value>false</value></constructor-arg>
</bean>
</entry>
</map>
</property>
</bean>
<bean id="datetestBean" class="com.huatek.model.DateTestBean">
<property name="date"> <value>1981-01-01</value> </property>
</bean>
<bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="java.util.Date">
<bean class="org.springframework.beans.propertyeditors.CustomDateEditor">
<constructor-arg index="0">
<bean class="java.text.SimpleDateFormat">
<constructor-arg><value>yyyy-MM-dd</value></constructor-arg>
</bean>
</constructor-arg>
<constructor-arg index="1"><value>false</value></constructor-arg>
</bean>
</entry>
</map>
</property>
</bean>
<bean id="datetestBean" class="com.huatek.model.DateTestBean">
<property name="date"> <value>1981-01-01</value> </property>
</bean>
相关文章推荐
- Spring AMQP实例 以及Spring 配置文件动态注入属性使用实战
- Spring--IoC--域属性的注入-使用@Resource注解(JSR)
- spring 为某类注入的属性 其子类无法使用
- spring使用案例 属性注入
- Spring Boot系列五 Spring @Value 属性注入使用总结二
- spring中使用@RequestBody,对应的bean中属性名大写注入为空的解决方法
- Spring系列【09】使用<prop>标签为Java持久属性集注入值
- spring对Filter和Servlet无法使用自动注入属性解决方法
- Spring中使用Map、Set、List、数组、属性集合的注入方法配置文件
- 使用Spring配置shiro时,自定义Realm中属性无法使用注解注入解决办法
- Spring Boot系列 Spring @Value 属性注入使用总结一
- Spring中使用事务搭建转账环境方法二 相对简便的注解方法 ——配置文件注入对象属性需要setter方法 注解方法,不需要生成setter方法
- Spring中使用Map、Set、List、数组、属性集合的注入方法配置文件
- Spring第六弹—-依赖注入之使用构造器注入与使用属性setter方法注入
- spring:使用<prop>标签为Java持久属性集注入值
- Spring Web MVC使用技巧一则
- spring中使用@RequestBody,对应的bean中属性名大写注入为空的解决方法
- ASP.NET MVC 中使用Spring.NET实现简单的属性注入
- Spring根据XML配置文件注入属性 其实也是造bean,看看是使用constructor还是setter顺带完成属性赋值
- Spring中使用事务搭建转账环境方法二 相对简便的注解方法 ——配置文件注入对象属性需要setter方法 注解方法,不需要生成setter方法