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

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

时间2025-09-09 23:50:24分类IT科技浏览6274
导读: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
租香港服务器一个月多少钱(租用香港服务器如何维护数据安全) Vue前端开发实训报告(Vue.js 前端项目在常见 Web 服务器上的部署配置)