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;
}
}

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。