在Servlet中
方法一: 从ServletContext 取出 Spring容器上下文
ApplicationContext applicationContext = (ApplicationContext) this.getServletContext().getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
方法二: ApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());