ill Value To List

File:context.xml

<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEbeansPUBLIC"-//SPRING//DTDBEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">

<beans>

<beanid="collectionsExample"class="CollectionsBean">

<propertyname="theList">
<list>
<value>red</value>
<value>red</value>
<value>blue</value>

</list>
</property>

</bean>

<beanid="curDate"class="java.util.GregorianCalendar"/>

</beans>

File:Main.java

importjava.util.List;
importjava.util.Map;
importjava.util.Properties;
importjava.util.Set;

importorg.springframework.context.ApplicationContext;
importorg.springframework.context.support.ClassPathXmlApplicationContext;

classMain{
publicstaticvoidmain(Stringargs[])throwsException{
ApplicationContextctx=newClassPathXmlApplicationContext("context.xml");

CollectionsBeanexample=(CollectionsBean)ctx.getBean("collectionsExample");
System.out.println(example.getTheList());

}
}
classCollectionsBean{

privateListtheList;
privateSettheSet;
privateMaptheMap;
privatePropertiestheProperties;

publicvoidsetTheList(ListtheList){
this.theList=theList;
}
publicListgetTheList(){
returntheList;
}

publicvoidsetTheSet(SettheSet){
this.theSet=theSet;
}
publicSetgetTheSet(){
returntheSet;
}

publicvoidsetTheMap(MaptheMap){
this.theMap=theMap;
}
publicMapgetTheMap(){
returntheMap;
}

publicvoidsetTheProperties(PropertiestheProperties){
this.theProperties=theProperties;
}
publicPropertiesgetTheProperties(){
returntheProperties;
}
}

发表回复