在Spring框架下手工获取Bean的方式

ApplicationContext ac = new FileSystemXmlApplicationContext("applicationContext.xml");
    ac.getBean("beanId");


ApplicationContext ac1 = WebApplicationContextUtils.getRequiredWebApplicationContext(ServletContext sc)

ApplicationContext ac2 = WebApplicationContextUtils.getWebApplicationContext(ServletContext sc)

    ac1.getBean("beanId");

    ac2.getBean("beanId");


UserManager userManager = (UserManager) WebApplicationContextUtils.getRequiredWebApplicationContext(pageContext.getServletContext()).getBean("userManager");

你可能感兴趣的:(java,spring,bean,xml,框架)