Spring Bean 各种集合类型注入介绍
类结构如下之代码
package com.japie.injection;import java.util.Date;import java.util.List;import java.util.Map;import java.util.Set;/** * * @author Japie * 下午06:57:21 */public class Bean1 {private String strValue;private int intValue;private List listValue;private Set setValue;private String[] arrayValue;private Map mapValue;private Date dateValue;public String getStrValue() {return strValue;}public void setStrValue(String strValue) {this.strValue = strValue;}public int getIntValue() {return intValue;}public void setIntValue(int intValue) {this.intValue = intValue;}public List getListValue() {return listValue;}public void setListValue(List listValue) {this.listValue = listValue;}public Set getSetValue() {return setValue;}public void setSetValue(Set setValue) {this.setValue = setValue;}public String[] getArrayValue() {return arrayValue;}public void setArrayValue(String[] arrayValue) {this.arrayValue = arrayValue;}public Map getMapValue() {return mapValue;}public void setMapValue(Map mapValue) {this.mapValue = mapValue;}public Date getDateValue() {return dateValue;}public void setDateValue(Date dateValue) {this.dateValue = dateValue;}}
?配置文件如下
?
<bean id="bean1" value="Hello_Spring"/><property name="intValue"><value>123</value></property><property name="listValue"><list><value>list1</value><value>list2</value></list></property><property name="setValue"><set><value>set1</value><value>set2</value></set></property><property name="arrayValue"><list><value>array1</value><value>array2</value></list></property><property name="mapValue"><map><entry key="k1" value="v1"/><entry key="k2" value="v2"/></map></property><property name="dateValue" value="2011年06月17日" /></bean>