首页IT科技fill_value怎么用的(Fill Value To List : XML Bean Property « Spring « Java)

fill_value怎么用的(Fill Value To List : XML Bean Property « Spring « Java)

时间2025-07-10 18:17:47分类IT科技浏览5228
导读:ill Value To List...

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

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
网站seo技术能不能赚钱(掌握SEO的基本步骤,让你的网站轻松跻身前列) 打码赚钱软件哪个好用(什么网站可以打码赚钱吗-「重大揭秘」地下色情诱导网站,技术面深入分析他们的赚钱套路)