(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">
<list>
<value>list1</value>
<value>list2</value>
<value>list2</value>
</list>
</property>
</bean>
(2)Set注入方式:
<bean id="hello" class="com.gc.entity.HelloWorld">
<property name="msg">
<set>
<value>gc</value>
<value>gv</value>
</set>
</property>
</bean>
(3)Map注入方式:
<property name="msg">
<map>
<entry key="gc">
<value>Helloworld</value>
</entry>
<entry key="gv">
<value>Kitty</value>
</entry>
</map>
</property>
(4) Properties的注入
<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中去