Spring(五)集合的注入方式
(1)List 的注入方式:
package com.gc.entity;
import java.util.List;
public class HelloWorld {
?private List msg;
?public List getMsg() {
??return msg;
?}
?public void setMsg(List msg) {
??this.msg = msg;
?}
}
?
配置文件:
? <bean id="hello" class="com.gc.entity.HelloWorld">
?????? <property name="msg">
??????? <props>
???????? <prop key="gc">helloworld</prop>
???????? <prop key="gv">helloworld</prop>
??????? </props>
?????? </property>
??? </bean>
对于List、Set、Map、Properties的注入实际上时类似的,都需要把要注入的信息注入到集合中去,然后把相关的集合注入到Bean中去