TestUtil.java
1 package com.lh.util; 2 3 import java.util.List; 4 import java.util.Map; 5 import java.util.Set; 6 7 public class TestUtil { 8 @Override 9 public String toString() { 10 return "TestUtil [list=" + list + ", set=" + set + ", map=" + map + "]"; 11 } 12 13 private List<?> list; 14 private Set<?> set; 15 private Map<?, ?> map; 16 17 public void setList(List<?> list) { 18 this.list = list; 19 } 20 21 public void setSet(Set<?> set) { 22 this.set = set; 23 } 24 25 public void setMap(Map<?, ?> map) { 26 this.map = map; 27 } 28 29 public List<?> getList() { 30 return list; 31 } 32 33 public Set<?> getSet() { 34 return set; 35 } 36 37 public Map<?, ?> getMap() { 38 return map; 39 } 40 }
Spring配置文件
1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" 4 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd 5 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"> 6 7 <bean id="testUtil" class="com.lh.util.TestUtil"> 8 <property name="list"> 9 <list> 10 <value>list集合的第一个元素</value> 11 <value>list集合的第二个元素</value> 12 <value>list集合的第三个元素</value> 13 </list> 14 </property> 15 <property name="set"> 16 <set> 17 <value>张三*</value> 18 <value>李四*</value> 19 </set> 20 </property> 21 <property name="map"> 22 <map> 23 <entry key="key1" value="Java从基础到项目实战" /> 24 <entry key="key2" value="JavaWeb从基础到项目实战" /> 25 </map> 26 </property> 27 </bean> 28 </beans>
这个比较简单,就不再重复了。
时间: 2024-10-24 22:41:04