任意位置得到Spring bean
来源:互联网 发布:java上下文是什么意思 编辑:程序博客网 时间:2024/06/06 01:26
public class org.springframework.web.context.ContextLoaderListener
extends org.springframework.web.context.ContextLoader
implement javax.servlet.ServletContextListener {}
当结合Spring的时候我们首先要在web.xml启动Spring容器,所以会做如下配置:
<context-param><param-name>contextConfigLocation</param-name><param-value>classpath:Spring-Hibernate.xml,classpath:Spring-beans.xml</param-value></context-param><listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener>
ContextLoaderListener继承了ContextLoader,而ContextLoader有这样一个方法:
/** * Obtain the Spring root web application context for the current thread * (i.e. for the current thread's context ClassLoader, which needs to be * the web application's ClassLoader). * @return the current root web application context, or <code>null</code> * if none found * @see org.springframework.web.context.support.SpringBeanAutowiringSupport */public static WebApplicationContext getCurrentWebApplicationContext() {return (WebApplicationContext) currentContextPerThread.get(Thread.currentThread().getContextClassLoader());}
通过这个方法可以在任何地方得到WebApplicationContext,从而得到任意一个已注入的bean对象。
- 任意位置得到Spring bean
- java普通类在任意位置得到spring 中的bean
- java普通类在任意位置得到spring 中的bean
- java得到spring 中的bean
- Spring得到bean的值得
- Spring中利用容器得到Bean对象
- 在任意bean中获取spring上下文集合
- 简单的bean利用spring得到服务器上的路径
- spring工程中得到注入bean的集中方式
- 在filter注入或者是得到spring托管的bean
- Spring 中注入bean的properties配置文件位置问题解决
- Spring 中注入bean的properties配置文件位置问题解决
- 任意位置添加FLASH
- 任意位置拖动窗口
- Delphi-任意气泡位置
- Delphi-任意气泡位置
- 任意位置调用sideboxes
- AutoCompleteTextView任意位置匹配
- 水利水能规划—水电站水库特征参数选择——C++程序
- ubuntu 10.04 NFS配置
- Subversion 安装及配置说明(windows7)
- 使用git建立本地仓储管理代码
- redhat版本介绍
- 任意位置得到Spring bean
- Android之CountDownLatch线程同步
- C 语言 ---- 汉诺塔算法
- 第2章 Model View Controller
- local service and remote service(AIDL Service)
- HBase存储架构
- GetCurrentDirectory(255,buff);SetCurrentDirectory(TEXT("C:\\windows"));
- linux——posix标准下的信号量
- 生命的热情