一则spring中使用PropertyEditors 来注入日期型属性的技巧

来源:互联网 发布:dj软件打碟 编辑:程序博客网 时间:2024/04/24 20:41

如题。   

<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>   

原创粉丝点击