当applicationContext.xml在WEB_INFO下时,得到bean可以这样
ServletContext servletContext = ServletActionContext
.getServletContext();
WebApplicationContext cxt = WebApplicationContextUtils
.getWebApplicationContext(servletContext);
LDAPPersonDao personDao = (LDAPPersonDao) cxt.getBean("personDao");
当applicationContext.xml位于src下时,可以通过这样获得!!
ApplicationContext cxt = new ClassPathXmlApplicationContext("applicationContext.xml");
PersonDaoImpl personDao = (PersonDaoImpl)cxt.getBean("personDao");