手动从spring WebApplicationContext 获取bean (一)
来源:互联网 发布:电子地图标注软件破解 编辑:程序博客网 时间:2024/06/07 06:25
import org.springframework.beans.BeansException;import org.springframework.context.ApplicationContext;import org.springframework.context.ApplicationContextAware;/** * 手动从Spring WebApplicationContext 容器中获得bean */public class BeanUtils implements ApplicationContextAware { private static ApplicationContext applicationContext; public static Object getBean(String beanName) { return applicationContext.getBean(beanName); } public static <T> T getBean(String beanName, Class<T> clazs) { return clazs.cast(getBean(beanName)); } public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { BeanUtils.applicationContext = applicationContext; } }
配置文件<bean id="beanUtils" class="cn.xxx.util.BeanUtils" />
- 手动从spring WebApplicationContext 获取bean (一)
- spring拿到WebApplicationContext,获取bean
- 手动从spring BeanFactory 获取bean (二)
- 从servlet中获取spring的WebApplicationContext
- Spring手动获取指定Bean
- spring手动注册bean,移除bean,获取bean
- servlet中手动获取spring的bean
- 手动获取Spring上下文和Bean对象
- Struts2获取Spring的WebApplicationContext
- spring controller中获取webApplicationContext
- spring手动初始化bean
- 手动注册 spring bean
- 手动获取spring的ApplicationContext和bean对象
- 手动获取spring的ApplicationContext和bean对象
- 通过spring手动获取bean报空指针问题
- 手动获取spring的application和bean属性
- spring 从bean实例中获取对象
- Java从Spring中获取Bean
- 程序员面试题精选100题(32)-不能被继承的类
- How To Upgrade ASM from 10.2 to 11.1 (RAC)
- JTable表头排序的两种方法
- asp.net(c#) 使用xsl转换xml文件
- How to perform Rolling Upgrade-Downgrade in 11g ASM
- 手动从spring WebApplicationContext 获取bean (一)
- 2011.9.15-9.23周总结 & 迟来的咆哮
- How To Upgrade ASM from 10.2 to 11.1 (single Instance configuration -Non-RAC)
- Probability Theory
- listview单元格设置三种方法
- 7个超级实用的PHP代码片段
- 200个实用js
- html5本地存储localStorage实战(1)(转)
- 关于强类型Dataset出错提示未能启用约束。一行或多行中包含违反非空、唯一或外键约束的值