[英]How to get spring ApplicationContext in ServletContextListener?
In servet class it's possible to get spring ApplicationContext
this way 在服务类中,可以通过这种方式获取spring
ApplicationContext
ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
How to access ApplicationContext
in ServletContextListener
since getServletContext()
method is not accessible there? 由于无法在其中访问
getServletContext()
方法,如何在ServletContextListener
访问ApplicationContext
?
In contextInitialized
: 在
contextInitialized
:
public void contextInitialized(final ServletContextEvent event)
{
ApplicationContext appCtx = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.