sesion applicaiton调用spring bean

来源:互联网 发布:台式机品牌推荐 知乎 编辑:程序博客网 时间:2024/05/21 00:18

 

 

public void contextInitialized(ServletContextEvent arg0) {


         ServletContext app = arg0.getServletContext();
         ApplicationContext appli = WebApplicationContextUtils.getWebApplicationContext(app);
         SysModuleService ser = (SysModuleService)appli.getBean("sysModuleService");
         List<SysModule> sysModule = ser.listSysModule();
         app.setAttribute("sysModule", sysModule);

    }

 

 

 

 

public void sessionCreated(HttpSessionEvent arg0) {
        HttpSession session = arg0.getSession();
        WebApplicationContextUtils.getWebApplicationContext(session.getServletContext());

        .... .....
        session.setAttribute("WebMidetailPageNo", WebMidetailPageNo);
        session.setAttribute("WebMiclassPageNo", WebMiclassPageNo);
    }