在servet类中,可以这样获得spring ApplicationContext
ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());如何在ServletContextListener中访问ServletContextListener,因为getServletContext()方法在那里是不可访问的?
发布于 2015-12-11 07:16:40
在contextInitialized中:
public void contextInitialized(final ServletContextEvent event)
{
ApplicationContext appCtx = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
}https://stackoverflow.com/questions/34218008
复制相似问题