ApplicationContext获取上下文。
(1)在java文件中:主要用于jUnit测试1导包:2importorg.springframework.context.ApplicationContext;3importorg.springframework.context.support.ClassPathXmlApplicationContext;4获取bean:5ApplicationContext context =newClassPathXmlApplicationContext("beans.xml");6UserDao userDao = (UserDao) context.getBean("userDao", UserDao.
在jsp文件中测试:1引用相关类:2<%@pageimport="org.springframework.web.context.WebApplicationContext"%3<%@pageimport="org.springframework.web.context.support.WebApplicationContextUtils"%4获取bean:5WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(this