通过spring静态获取对象

1、ApplicationContext ac= WebApplicationContextUtils.getRequiredWebApplicationContext(request.getSession()
            .getServletContext());
         BeanFactory bf = (BeanFactory)ac;
         userPowerService = (UserPowerService)bf.getBean("userPowerService");

 

 

 

2、ApplicationContext acx = new FileSystemXmlApplicationContext("/config/applicationContext.xml");
        MultiCataService mulCataService = (MultiCataService) acx.getBean("MultiCataService");

posted @ 2012-07-03 15:41  狼里格朗  阅读(282)  评论(0编辑  收藏  举报