springMVC 使用WebApplicationContext获取ApplicationContext对象
来源:互联网 发布:网络性能指标并发 编辑:程序博客网 时间:2024/06/05 06:07
主要用于从application中获取bean
1、applicationContext
在web.xml中使用listener配置
<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value></context-param><listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener>
使用WebApplicationContext获取
WebApplicationContext webApplicationContext =ContextLoader.getCurrentWebApplicationContext();
2、springMVC-serlvet
在web.xml中使用servlet配置
<servlet> <servlet-name>springMVC</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:springMVC-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup></servlet><servlet-mapping> <servlet-name>springMVC</servlet-name> <url-pattern>/</url-pattern></servlet-mapping>
使用ServletContext获取
ServletContext servletContext=request.getSession().getServletContext();WebApplicationContext webApplicationContext = (WebApplicationContext)servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
0 0
- springMVC 使用WebApplicationContext获取ApplicationContext对象
- springmvc 获取ApplicationContext对象
- Spring获取webapplicationcontext,applicationcontext几种方法
- spring获取webapplicationcontext,applicationcontext几种方法
- spring获取webapplicationcontext,applicationcontext几种方法
- ApplicationContext,WebApplicationContext
- ApplicationContext,WebApplicationContext
- springmvc获取上下文ApplicationContext
- SpringMVC获得ApplicationContext对象
- SpringMVC中在Filter中如何获取ApplicationContext对象
- Spring获取WebApplicationContext与ApplicationContext的几种方法分析
- spring获取webapplicationcontext,applicationcontext几种方法详解
- Spring获取WebApplicationContext与ApplicationContext的几种方法分析
- spring获取webapplicationcontext,applicationcontext几种方法详解
- spring获取webapplicationcontext,applicationcontext几种方法详解
- spring获取webapplicationcontext,applicationcontext几种方法详解
- spring获取webapplicationcontext,applicationcontext几种方法详解
- spring获取webapplicationcontext,applicationcontext几种方法详解
- sql
- centos 6.5图形界面和命令行界面切换
- 不要忽视信噪比
- [ORACLE]BBED之基础篇
- HDU1711 Number Sequence
- springMVC 使用WebApplicationContext获取ApplicationContext对象
- GDI +发生一般性错误
- 理解矩阵(二)
- 学习新东西的基本套路
- ASP.NET Web API 简介
- Sublime Text 2 入门及技巧
- C#开发的较好的FTP类
- 自定义类可序列化
- 常用链接整理(2014-09-18)