java spring 属性注入 备忘

<bean id="" class="">
<property name="strValue" value="string1">
<property name="intValue" value="123"/>
<property name="intValue" value="123">
    <value>123</value>
</property>
<property name="listValue">
    <list>
        <value>value1</value>
        <value>value2</value>
    </list>
</property>
<property name="setValue">
    <set>
        <value>v1</value>
        <value>v2</value>
    </set>
</property>
<property name="arrayValue">
    <list>
        <value>value1</value>
        <value>value2</value>
    </list>
</property>
<property name="mapValue">
    <map>
        <entry key="1" value="asdf"/>
        <entry key="2" value="asdf"/>
    </map>
</property>
<property name="dateValue">
    <value>2001-1-12</value>
</property>
</bean>



<bean id="" class="org.springframework.beans.factory.config.CustomEditorConfigurer">
    <property name="customEditors">
    <map>
    <entry key="java.util.Date">
        <bean class="....UtilDatePropertyEditor">
            <property name="format" value="yyyy-MM-dd" />
        </bean>
    <entry>
    </map>
    </property>
</bean>

UtilDatePropertyEditor extends PropertyEditorSupport{
    @Override
    public void setAsText(String text) throws IllegalArgumentException{
        SimpleDateFormat sfd = new SimpleDateFormat("yyyy-MM-dd");
        this.setValue(sfd.parse(text););
    }
}

你可能感兴趣的:(spring)