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