标签:his cat mes style return type info span name
集合注入
Member
1 public class Member { 2 private List<String> names ; 3 private Set<String> emails ; 4 private Map<String,String> tels ; 5 private Properties infos ; 6 7 public Properties getInfos() { 8 return infos; 9 } 10 11 public void setInfos(Properties infos) { 12 this.infos = infos; 13 } 14 15 public List<String> getNames() { 16 return names; 17 } 18 19 public void setNames(List<String> names) { 20 this.names = names; 21 } 22 23 public Set<String> getEmails() { 24 return emails; 25 } 26 27 public void setEmails(Set<String> emails) { 28 this.emails = emails; 29 } 30 31 public Map<String, String> getTels() { 32 return tels; 33 } 34 35 public void setTels(Map<String, String> tels) { 36 this.tels = tels; 37 } 38 39 @Override 40 public String toString() { 41 return "Member [names=" + names + ", emails=" + emails + ", tels=" + tels + ", infos=" + infos + "]"; 42 } 43 }
applicationContext.xml
在默认情况下会用ArrayList为List接口实例化。
LinkedHashSet实例化Set 。结合了List的顺序保存,和Set的不容许重复。
<bean id="member" class="cn.mldn.vo.Member" >
<property name="names" >
<!-- 这里不写value-type 也可以正确为集合设置内容 -->
<list value-type="java.lang.String">
<value>Smith</value>
<value>Tony</value>
<value>Smith</value>
</list>
</property>
<property name="emails">
<set>
<value>test_123@qq.com</value>
<value>xiaohuang@163.com</value>
<value>bupbi@qq.com</value>
<value>bupbi@qq.com</value>
</set>
</property>
<property name="tels">
<map>
<entry key="110" value="公安" />
<entry>
<key><value>120</value></key>
<value>急救</value>
</entry>
</map>
</property>
<property name="infos">
<props>
<prop key="mldn">www.mldn.cn</prop>
<prop key="asdf">asdfasdfas</prop>
</props>
</property>
</bean>
标签:his cat mes style return type info span name
原文地址:https://www.cnblogs.com/blog-747674599/p/9911742.html