1、
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
Student stu = (Student)context.getBean("student");
stu.setEmail("abc@126.com");
2、
String filePath = SpringAction.class.getResource("/").getPath();
filePath = filePath.substring(1);
Resource resource = new FileSystemResource(filePath+"applicationContext.xml");
BeanFactory factory = new XmlBeanFactory(resource);
Student stu1 = (Student)factory.getBean("student");
stu1.setEmail("abc@163.com");
3、
ClassPathResource cr = new ClassPathResource("applicationContext.xml");
BeanFactory beans = new XmlBeanFactory(cr);
Student stu2 = (Student)beans.getBean("student");
stu2.setEmail("abc@qq.com");