1. 程式人生 > >Spring裝配各種集合型別的配置檔案

Spring裝配各種集合型別的配置檔案

1、 list集合

<bean id="userService" class="com.spring.service.UserService">
	<property name="list">
  		<list>
  		    	<value>aaaa</value>
  			<value>bbbb</value>
  		</list>
  	</property>
 </bean>

2、set集合

 <bean id="userService" class="com.spring.service.UserService">
  	<property name="set">
  		<set>
  			<value>cccc</value>
  			<value>dddd</value>
  		</set>
  	</property>
</bean>

3、map集合

<bean id="userService" class="com.spring.service.UserService">
  	<property name="set">
  		<map>
  			<entry key="1111" value="aaaa"/>
  			<entry key="2222" value="bbbb"/>
  		</map>
  	</property>
</bean>


4、properties

<bean id="userService" class="com.spring.service.UserService">
<property name="pro">
  			<props>
  				<prop key="1111">aaaa</prop>
  				<prop key="2222">cccc</prop>
  			</props>	
 		</property>
</bean>