1、ServletContext sc=request.getSession().getServletContext();
WebApplicationContext context=(WebApplicationContext)request.getAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE);
2、 ServletContext sc=request.getSession().getServletContext();
WebApplicationContext context=WebApplicationContextUtils.getWebApplicationContext(sc);
第二种方式取得的ApplicationContext是Spring容器的上下文