Web容器中获取spring容器的bean对象
来源:互联网 发布:c 高级编程 第8版 编辑:程序博客网 时间:2024/05/17 07:59
1.实现ApplicationContextAware接口
public class SpringContextUtil implements ApplicationContextAware {// Spring应用上下文环境private static ApplicationContext applicationContext;/** * 实现ApplicationContextAware接口的回调方法,设置上下文环境 * * @param applicationContext */public void setApplicationContext(ApplicationContext applicationContext) {SpringContextUtil.applicationContext = applicationContext;}/** * @return ApplicationContext */public static ApplicationContext getApplicationContext() {return applicationContext;}/** * 获取对象 * @param name * @return Object * @throws BeansException */public static Object getBean(String name) throws BeansException {return applicationContext.getBean(name);}}
2.配置文件需要配置
<bean id="springContextUtil" class="com.test.util.SpringContextUtil" lazy-init="false" />
0 0
- Web容器中获取spring容器的bean对象
- 在web容器中获取spring容器中的bean对象
- 获取Spring 容器中bean的方法
- 获取spring容器中bean的方法
- 在web容器中获取spring容器对象
- 在filter中获取spring容器中的bean对象
- 获取Spring的Bean持有容器对象的方法
- web容器中获取spring容器实例
- Bean获取Spring容器
- Bean获取Spring容器
- 从spring容器中获取bean
- Spring中利用容器得到Bean对象
- Spring动态获取IoC容器中管理的Bean
- Spring线程获取容器中bean的方法
- 从Spring容器中获取bean的几种方式
- 获取Spring容器中Bean的工具类
- 【Spring】Spring容器获取Bean
- java类获取spring容器的bean
- 1046: 最小的K个数
- freemarker使用技巧
- HDU 2063 过山车 [二分图匹配] [匈牙利算法]
- Java集合---ArrayList的实现原理
- 2016 Multi-University Training Contest 8 题解
- Web容器中获取spring容器的bean对象
- 关于UINavigationBar 隐藏底部黑线的方法
- H5+ 图片压缩上传
- Android开发之NDK(JNI)
- pdf电子书
- opencv初学
- python连接mysql数据库实战
- CSS3动画效果二
- HashTable、HashSet和Dictionary的区别