集合类型如下:
private int[] array;
private List<String> list;
private Set<String> set;
private Map<String,String> map;
private Properties properties;
首先先设置setter方法
public void setArray(int[] array) {
this.array = array;
}
public void setList(List<String> list) {
this.list = list;
}
public void setSet(Set<String> set) {
this.set = set;
}
public void setMap(Map<String, String> map) {
this.map = map;
}
public void setProperties(Properties properties) {
this.properties = properties;
}
然后,在bean中设置
<?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">
<bean id="bookDao" class="com.hyk.dao.impl.BookDaoImpl">
<property name="array">
<array>
<value>1</value>
<value>2</value>
<value>3</value>
</array>
</property>
<property name="list">
<list>
<value>abc</value>
<value>zxc</value>
</list>
</property>
<property name="set">
<set>
<value>abc</value>
<value>zxc</value>
<value>abc</value>
</set>
</property>
<property name="map">
<map>
<entry key="country" value="china"/>
<entry key="province" value="jiangsu"/>
<entry key="city" value="wuxi"/>
</map>
</property>
<property name="properties">
<props>
<prop key="country">中国</prop>
<prop key="province">江苏</prop>
<prop key="city">无锡</prop>
</props>
</property>
</bean>
</beans>
运行结果: