这是当时看某up主视频记的东西,太多,也不整理了。用的时候肯定能在里面找到自己要的足矣。
package com.xxx;
public class Address {
private String address;
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
package com.xxx;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
public class Satudent {
private String name;
private Address address;
private String[] books;
private List<String> hobbys;
private Map<String,String> card;
private Set<String> games;
private String wife;
private Properties info;
public void setName(String name) {
this.name = name;
}
public void setAddress(Address address) {
this.address = address;
}
public void setBooks(String[] books) {
this.books = books;
}
public void setHobbys(List<String> hobbys) {
this.hobbys = hobbys;
}
public void setCard(Map<String, String> card) {
this.card = card;
}
public void setGames(Set<String> games) {
this.games = games;
}
public void setWife(String wife) {
this.wife = wife;
}
public void setInfo(Properties info) {
this.info = info;
}
public void show(){
System.out.println("name="+ name
+ ",address="+ address.getAddress()
+ ",books="
);
for (String book:books){
System.out.print("<<"+book+">>\t");
}
System.out.println("\n爱好:"+hobbys);
System.out.println("card:"+card);
System.out.println("games:"+games);
System.out.println("wife:"+wife);
System.out.println("info:"+info);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="student" class="com.xxx.Student">
<property name="name" value="小明同学"></property>
<property name="address" ref="addr"></property>
<property name="books">
<array>
<value>西游记</value>
<value>红楼梦</value>
</array>
</property>
<property name="hobbys">
<list>
<value>听歌</value>
<value>看电影</value>
</list>
</property>
<property name="card">
<map>
<entry key="中国邮政" value="123"></entry>
<entry key="中国建设" value = "456"></entry>
</map>
</property>
<property name="games">
<set>
<value>LOL</value>
<value>BOB</value>
</set>
</property>
<property name="info">
<props>
<prop key="学号">20091812</prop>
<prop key="性别">男</prop>
<prop key="姓名">小明</prop>
</props>
</property>
<property name="wife"><null></null></property>
</bean>
<bean id="addr" class="com.xxx.Address">
<property name = "address" value = "北京市"></property>
</bean>
</beans>