fill_value怎么用的(Fill Value To List : XML Bean Property « Spring « Java)
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; } }
创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!