package com.sqc.base;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
//web容器启动监听器
public class InitListener implements ServletContextListener {
@Override
public void contextDestroyed(ServletContextEvent arg0) {
}
/**
* 为保证只有一个spring容器,所以在web容器初始化方法中通过spring提供的工具类,获取spring容器实例
*/
@Override
public void contextInitialized(ServletContextEvent arg0) {
ApplicationContext ac=WebApplicationContextUtils.getWebApplicationContext(arg0.getServletContext());
}
}
web容器中获取spring容器实例
最新推荐文章于 2023-04-05 19:51:09 发布