对应的实体
public class User {
// id
private int id;
// 年龄
private int age;
// 编号
private long code;
// 分数
private float score;
// 钱
private double money;
// 状态
private Boolean flag;
// 姓名
private String username;
// 密码
private String password;
// 出生日期
private String date;
//我的帮助人
private Teacher teacher;
// 指导老师
private List<String> teachers;
// 主任老师
private HashMap<String, Object> teacherMap;
// 所有的同学
private String[] users;
private List<HashMap<String, Object>> listMaps;
// 很多的书本
private Set<String> books;
private List<String[]> listArray;
private HashMap<String, String[]> mapArray;
private List<Teacher> teacherList;
private HashMap<String, Teacher> teacherMaps;
public void userInfo() {
System.out.println("我是keke老师");
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public long getCode() {
return code;
}
public void setCode(long code) {
this.code = code;
}
public float getScore() {
return score;
}
public void setScore(float score) {
this.score = score;
}
public double getMoney() {
return money;
}
public void setMoney(double money) {
this.money = money;
}
public Boolean getFlag() {
return flag;
}
public void setFlag(Boolean flag) {
this.flag = flag;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public Teacher getTeacher() {
return teacher;
}
public void setTeacher(Teacher teacher) {
this.teacher = teacher;
}
public List<String> getTeachers() {
return teachers;
}
public void setTeachers(List<String> teachers) {
this.teachers = teachers;
}
public HashMap<String, Object> getTeacherMap() {
return teacherMap;
}
public void setTeacherMap(HashMap<String, Object> teacherMap) {
this.teacherMap = teacherMap;
}
public String[] getUsers() {
return users;
}
public void setUsers(String[] users) {
this.users = users;
}
public List<HashMap<String, Object>> getListMaps() {
return listMaps;
}
public void setListMaps(List<HashMap<String, Object>> listMaps) {
this.listMaps = listMaps;
}
public Set<String> getBooks() {
return books;
}
public void setBooks(Set<String> books) {
this.books = books;
}
public List<String[]> getListArray() {
return listArray;
}
public void setListArray(List<String[]> listArray) {
this.listArray = listArray;
}
public HashMap<String, String[]> getMapArray() {
return mapArray;
}
public void setMapArray(HashMap<String, String[]> mapArray) {
this.mapArray = mapArray;
}
public List<Teacher> getTeacherList() {
return teacherList;
}
public void setTeacherList(List<Teacher> teacherList) {
this.teacherList = teacherList;
}
public HashMap<String, Teacher> getTeacherMaps() {
return teacherMaps;
}
public void setTeacherMaps(HashMap<String, Teacher> teacherMaps) {
this.teacherMaps = teacherMaps;
}
}
对应的xml配置:
<bean id="teacher" class="com.Entity.Teacher">
<property name="usrename" value="柯柯老师"></property>
<property name="password" value="000000"></property>
</bean>
<bean id="teacher2" class="com.Entity.Teacher">
<property name="usrename" value="Array老师"></property>
<property name="password" value="000000"></property>
</bean>
<bean id="user01" class="com.Entity.User">
<property name="id" value="1"></property>
<property name="username" value="天堂"></property>
<property name="password" value="111111111111"></property>
<property name="code" value="1000"></property>
<!-- 日期怎么处理? -->
<property name="date" value="2015-01-11 11:11:23"></property>
<property name="score" value="100"></property>
<property name="flag" value="true"></property>
<property name="teacher" ref="teacher"></property>
<!-- list的方式 -->
<property name="teachers">
<list>
<value>keke老师</value>
<value>arry老师</value>
<value>小威老师</value>
</list>
</property>
<!-- map的方式 -->
<property name="teacherMap">
<map>
<entry key="name" value="keke"></entry>
<entry key="age" value="29"></entry>
</map>
</property>
<!-- 数组 -->
<property name="users">
<array>
<value>robin</value>
<value>淘宝</value>
<value>单晨</value>
</array>
</property>
<!-- listHashMap -->
<property name="listMaps">
<list>
<map><entry key="username" value="文剑 "></entry></map>
<map><entry key="username" value="媳妇"></entry></map>
<map><entry key="username" value="阿图 "></entry></map>
</list>
</property>
<!-- set的方式 -->
<property name="books">
<set>
<value>Java面向对象</value>
<value>会计学</value>
<value>国际贸易理论</value>
</set>
</property>
<!-- 集合数组 -->
<property name="listArray">
<list>
<array>
<value>robinList</value>
<value>淘宝List</value>
<value>单晨List</value>
</array>
<array>
<value>robinArray</value>
<value>淘宝Array</value>
<value>单晨Array</value>
</array>
</list>
</property>
<!-- map数组 -->
<property name="mapArray">
<map>
<entry key="usernameArry">
<array>
<value>小二</value>
<value>士大夫</value>
<value>发过火</value>
</array>
</entry>
<entry key="usernameArry2">
<array>
<value>小二sdfsd</value>
<value>士大夫fghfgh</value>
<value>发过火sdfsdfs</value>
</array>
</entry>
</map>
</property>
<!-- 集合对象 -->
<property name="teacherList">
<list>
<ref bean="teacher"/>
<ref bean="teacher2"/>
</list>
</property>
<!-- map对象 -->
<property name="teacherMaps">
<map>
<entry key="keke" value-ref="teacher"></entry>
<entry key="arry" value-ref="teacher2"></entry>
</map>
</property>
</bean>