private String[] myStrs; private List<String> myList; private Set<String> mySet; private Map<String,String> myMap; private Properties myProps;
<!--复杂类型的注入/集合类型的注入--> <bean id="accountService3" class="com.itheima.service.impl.AccountServiceImpl3"> <property name="myStrs"> <array> <value>AAA</value> <value>BBB</value> <value>CCC</value> </array> </property> </bean>
<!--复杂类型的注入/集合类型的注入--> <bean id="accountService3" class="com.itheima.service.impl.AccountServiceImpl3"> <property name="myList"> <list> <value>AAA</value> <value>BBB</value> <value>CCC</value> </list> </property> </bean>
<!--复杂类型的注入/集合类型的注入--> <bean id="accountService3" class="com.itheima.service.impl.AccountServiceImpl3"> <property name="mySet"> <set> <value>AAA</value> <value>BBB</value> <value>CCC</value> </set> </property> </bean>
<!--复杂类型的注入/集合类型的注入--> <bean id="accountService3" class="com.itheima.service.impl.AccountServiceImpl3"> <property name="myMap"> <map> <entry key="testA" value="aaa"></entry> <entry key="testB" value="bbb"></entry> <entry key="testC" value="ccc"></entry> </map> </property> </bean>
<!--复杂类型的注入/集合类型的注入--> <bean id="accountService3" class="com.itheima.service.impl.AccountServiceImpl3"> <property name="myMap"> <props> <prop key="testA">aaa</prop> <prop key="testB">bbb</prop> <prop key="testC">ccc</prop> </props> </property> </bean>
用于给List结构集合注入的标签:
list array set
用于给Map结构集合注入的标签:
map props
结构相同,标签可以互换。