一.Teacher类中包含的属性
private Integer tid;
private String tname;
private List<String> courses; //表示该老师教授课程名
private List<Student> students; //表示该老师所教授的学生
private Map<String,String> day_works; //表示每天的任务
private Map<String,Student> day_students; //表示每天辅导的学生
private Map<Student,Student> student_students; //表示结对学习
二.集合框架
1.List结构字段 List<>
i.value方式赋值
<bean id="teacher2" class="com.school.Teacher">
<property name="tid" value="20150002"></property>
<property name="tname" value="Zhou Jianping"></property>
<property name="courses">
<list>
<value>English</value>
<value>Chinese</value>
<value>Math</value>
</list>
</property>
</bean>
ii.ref引用赋值
<bean id="teacher3" class="com.school.Teacher">
<property name="tid" value="20150003"></property>
<property name="tname" value="Zhu Hanqin"></property>
<property name="students">
<list>
<ref bean="student2" />
<ref bean="student3" />
<ref bean="student4" />
</list>
</property>
</bean>
2.Map结构字段 Map<>
Map<键,值>:当键和值为普通字面量时用value包裹,非字面量可以采用ref引用,甚至可能采取嵌套的方式
<map>
<entry>
<key>
<value>键</value>
</key>
<value>值</value>
</entry>
</map>
<map>
<entry>
<key>
<ref bean="student10" />
</key>
<ref bean="student12" />
</entry>
</map>
i.<String,String>类型(此处用String代表一般字面量,可根据实际需要换成其他类型)
<bean id="teacher4" class="com.school.Teacher">
<property name="tid" value="20150004"></property>
<property name="tname" value="Zhao Yu"></property>
<property name="day_works">
<map>
<entry>
<key>
<value>Monday</value>
</key>
<value>安排本周教学计划</value>
</entry>
<entry>
<key>
<value>Tuesday</value>
</key>
<value>家访</value>
</entry>
</map>
</property>
</bean>
ii.<String,Object>类型
<bean id="teacher5" class="com.school.Teacher">
<property name="tid" value="20150005"></property>
<property name="tname" value="Feng Zhigang"></property>
<property name="day_students">
<map>
<entry>
<key>
<value>Monday</value>
</key>
<ref bean="student12" />
</entry>
<entry>
<key>
<value>Tuesday</value>
</key>
<ref bean="student11" />
</entry>
</map>
</property>
</bean>
iii.<Object,Object>
<bean id="teacher6" class="com.school.Teacher">
<property name="tid" value="20150006"></property>
<property name="tname" value="Zhang Zhanni"></property>
<property name="student_students">
<map>
<entry>
<key>
<ref bean="student10" />
</key>
<ref bean="student12" />
</entry>
<entry>
<key>
<ref bean="student9" />
</key>
<ref bean="student11" />
</entry>
</map>
</property>
</bean>
3.bean共享集合对象
<util:list id="courses">
<value>English</value>
<value>Chinese</value>
<value>Math</value>
</util:list>
<util:map id="map_day_student">
<entry>
<key>
<value>Monday</value>
</key>
<ref bean="student5" />
</entry>
<entry>
<key>
<value>Tuesday</value>
</key>
<ref bean="student6" />
</entry>
</util:map>
<bean id="teacher7" class="com.school.Teacher">
<property name="tid" value="20150007"></property>
<property name="tname" value="Han Jian"></property>
<property name="courses">
<ref bean="courses" />
</property>
<property name="day_students">
<ref bean="map_day_student" />
</property>
</bean>
<bean id="teacher8" class="com.school.Teacher">
<property name="tid" value="20150008"></property>
<property name="tname" value="Liu Guichao"></property>
<property name="courses">
<ref bean="courses" />
</property>
<property name="day_students">
<ref bean="map_day_student" />
</property>
</bean>