spring入门(5) spring中遍历各种集合2013-07-18 csdn 史国旭spring-collection.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"><!-- spring容器 就是负责创建、管理、维护Bean 并且能够依赖注入到相应组件上 --><bean id="collectionBean" class="www.csdn.spring.collection.set.CollectionBean" scope="singleton" lazy-init="default"><!-- set集合 --><property name="sets"><set><value>岑红军</value><value>军哥</value><value>哈哈</value><value>呵呵</value><value>嘿嘿</value><value>洗洗</value></set></property><!-- list集合 --> <property name="users"><!-- <list><ref bean="u1" /><ref bean="u2" /><ref bean="u3" /><ref bean="u4" /></list> --><array><ref bean="u1" /><ref bean="u2" /><ref bean="u3" /><ref bean="u4" /></array></property><!-- map --><property name="map"><map><entry key="1" value-ref="u1"></entry><entry key="2"><ref bean="u2" /></entry><entry key="3" value-ref="u3"></entry></map></property><property name="props"><props><prop key="1">jdbc:oracle</prop><prop key="2">jdbc:mysql</prop><prop key="3">jdbc:access</prop></props></property></bean><bean id="u1" class="www.csdn.spring.collection.set.User"><property name="name" value="deep"/><property name="age" value="21"/></bean><bean id="u2" class="www.csdn.spring.collection.set.User"><property name="name" value="deepsoul"/><property name="age" value="22"></property></bean><bean id="u3" class="www.csdn.spring.collection.set.User"><property name="name" value="chrp"/><property name="age" value="23"/></bean><bean id="u4" class="www.csdn.spring.collection.set.User"><property name="name" value="redarmy"/><property name="age" value="28"/></bean></beans>