<bean id="studentDao" class="oe.spring.StudentDaoImpl">
<property name="school">
<value>shida</value>
</property>
<property name="address">
<value>cangshan</value>
</property>
<property name="">
<list>
<value>90</value>
<value>80</value>
<value>50</value>
</list>
</bean>
<property name="school">
<value>shida</value>
</property>
<property name="address">
<value>cangshan</value>
</property>
<property name="">
<list>
<value>90</value>
<value>80</value>
<value>50</value>
</list>
</bean>
public BeanFactory
{
private static StudentDaoImpl dao;
private DaoFactory(){}
public static StudentDaoImpl getDao(){
if(dao == null){
dao = new StudentDaoImpl()
dao.setSchool("shida");
dao.setAddress("cangshan");
List list = new ArrayList();
list.add(new Integer(90));
list.add(new Integer(80));
list.add(new Integer(50));
dao.setMark(list);
}
return dao;
}
}
import java.util.ArrayList;
import java.util.List;public class Test { /**
* @param args
*/
public static void main(String[] args) {
// TODO 自动生成方法存根 StudentDaoImpl student = new StudentDaoImpl();
student.setSchool("shida");
student.setAddress("cangshan");
List list = new ArrayList();
list.add(90);
list.add(80);
list.add(50);
student.setMark(list); }}class StudentDaoImpl { private String school; private String address; private List ; public String getAddress() {
return address;
} public void setAddress(String address) {
this.address = address;
} public List getMark() {
return ;
} public void setMark(List ) {
this. = ;
} public String getSchool() {
return school;
} public void setSchool(String school) {
this.school = school;
}}
import java.util.ArrayList;
import java.util.List;
public class Util { /**
* @param args
*/
public static void main(String[] args) {
// TODO 自动生成方法存根
StudentDaoImpl student = new StudentDaoImpl();
student.setSchool("shida");
student.setAddress("cangshan");
List list = new ArrayList();
list.add(90);
list.add(80);
list.add(50);
student.setMark(list); }
}
class StudentDaoImpl{},set和get方法在spring 注入时生成!!
studentDao.setSchool("shida");
studentDao.setAddress("cangshan");
List list = new ArrayList();
list.add("90");
list.add("80");
list.add("50");
studentDao.setMark(new ArrayList());
import java.util.*;
import oe.spring.StudentDaoImplpublic class Untitled3 {
public Untitled3() {
} public void good() {
StudentDaoImpl studentDao = new StudentDaoImpl();
studentDao.setSchool("shida");
studentDao.setAddress("cangshan");
List list = new ArrayList();
list.add("90");
list.add("80");
list.add("50");
studentDao.setMark(new ArrayList());
}
}