スプリングのアセンブリ
一、リストセットを組み立てる.リスト中の要素はいずれの要素であってもよく、
、[、]をサブラベルとして使用することができる.xmlファイルの一部のコード:<bean id="collections" class="cn.csdn.collection.Collections">
<!-- list -->
<property name="list">
<list>
<value>guo</value>
<value>zhang</value>
<value>hao</value>
<value>hu</value>
<value>wang</value>
<value>yan</value>
<value>mi</value>
<value>bai</value>
</list>
</property>
<!-- list-->
<property name="liststu">
<list>
<ref bean="student" />
</list>
</property>
</bean>
二、セットセットを組み立てる.セットセットはlistと同じで、セットセット中の要素はいずれの要素でもよいが、セットは重複を許さず、重複が上書きされると異常を報告しない.xmlファイルの一部のコード:<bean id="collections" class="cn.csdn.collection.Collections">
<!-- set<String> -->
<property name="set">
<set>
<value>guo</value>
<value>guo1</value>
<value>guo2</value>
<value>guo3</value>
<value>guo4</value>
<value>guo5</value>
</set>
</property>
<!-- set<Object> -->
<property name="setstu">
<set>
<ref bean="student" />
</set>
</property>
</bean>
三、Mapコレクションを組み立てる.entryはmapのキーであり、entryの要素はいずれの要素でもよく、xmlファイルの一部のコード:<bean id="collections" class="cn.csdn.collection.Collections">
<!-- map -->
<property name="map">
<map>
<entry key="1">
<value>guo</value>
</entry>
<entry key="2">
<value>guoqian</value>
</entry>
<entry key="3">
<value>guoqianfang</value>
</entry>
<entry key="4">
<value>guo_qianfang</value>
</entry>
</map>
</property>
<!-- map<String,Object> -->
<property name="mapstu">
<map>
<entry key="1">
<ref bean="student" />
</entry>
</map>
</property>
</bean>
四、propertiesコレクションを組み立てる、xmlファイルの一部のコード<bean id="collections" class="cn.csdn.collection.Collections"
scope="singleton">
<!-- properties -->
<property name="prop">
<props>
<prop key="driverClass">com.mysql.jdbc.Driver</prop>
<prop key="url">jdbc/mysql://localhost:3306/db</prop>
<prop key="username">guo</prop>
<prop key="password">123</prop>
</props>
</property>
</bean>
五、null値を設定し、xmlファイルの一部のコードを設定する.<bean id="collections" class="cn.csdn.collection.Collections">
<!-- -->
<!-- spring2.0 3.0 -->
<property name="name">
<null />
</property>
<!-- spring2.0 3.0 -->
<property name="stu">
<null />
</property>
<!--
[color=red]spring3.0 spring2.0 [/color]
<property name="name">
<value>null</value>
</property>
spring3.0 spring2.0
<property name="stu">
<value>null</value>
</property>
-->
</bean>