首页 | 联系我们 | 叶凡网络官方QQ群:323842844
游客,欢迎您! 请登录 免费注册 忘记密码
您所在的位置:首页 > 开发语言 > Java开发 > 正文

关于集合属性的注入

作者:cocomyyz 来源: 日期:2013-08-04 23:43:02 人气:22 加入收藏 评论:0 标签:java

现在有个类:

public abstract class Message {
private Set set;
private List list;
private Map map;
private Properties pro;
//setter方法免写
}


则注入这样写:

<bean id="message"
  class="springdemo.Message">
  <!-- the injection of the 'Set' collection -->
  <property name="set">
   <set>
    <value>aaa</value>
    <value>123</value>
    <ref bean="nowTime"/>
   </set>
  </property>
 
  <!-- the injection of the 'List' collection -->
  <property name="list">
   <list>
    <value>aaa</value>
    <value>123</value>
    <ref bean="nowTime"/>
    <value>Hello world!</value>
   </list>
  </property>
 
  <!-- the injection of the 'Map' collection -->
  <property name="map">
   <map>
    <entry key="1" value="aaa"></entry>
    <entry key="abc" value-ref="nowTime"></entry>
    <entry key-ref="nowTime" value-ref="beanA"></entry>
   </map>
  </property>
 
  <!-- the injection of the 'Property' -->
  <property name="pro">
   <props>
    <prop key="1">ddd</prop>
   </props>
  </property>
</bean>


本文网址:http://www.mingyangnet.com/html/java/161.html
读完这篇文章后,您心情如何?
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
更多>>网友评论
发表评论
编辑推荐
  • 没有资料