通过WebApplicationContextUtils工具类获取ApplicationContext对象
来源:互联网 发布:学python要多久 编辑:程序博客网 时间:2024/05/21 19:24
通过WebApplicationContextUtils工具类获取ApplicationContext对象.
只需要传入application对象即可.
如果使用了struts2框架,可以通过如下方式获取application对象:
ServletContext application = ServletActionContext.getRequest().getSession().getServletContext();
如果是过滤器的init方法中,可以通过如下方式
ServletContext application = config.getServletContext();
ServletContext application = request.getSession().getServletContext();
ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(application); UserDao bd = (UserDao)context.getBean(spring中配置bean ID的名称);
如果我们在项目启动的时候,无论是在过滤器还是拦截器中,需要获取某个bean对象,这种方法将是最可取的。
0 0
- 通过WebApplicationContextUtils工具类获取ApplicationContext对象
- 通过WebApplicationContextUtils工具类获取ApplicationContext对象
- Spring工具类:WebApplicationContextUtils
- Spring工具类:WebApplicationContextUtils
- Spring获取ApplicationContext对象工具类
- Spring工具WebApplicationContextUtils
- Spring获取ApplicationContext的工具类
- applicationContext对象获取方法
- 获取ApplicationContext对象
- javaweb获取ApplicationContext对象
- springmvc 获取ApplicationContext对象
- grails 通过applicationContext获取bean
- Spring,通过ApplicationContextAware获取ApplicationContext
- WebApplicationContextUtils
- WebApplicationContextUtils
- 02_spring通过xml获取ApplicationContext
- Spring通过ApplicationContext主动获取bean
- Spring通过ApplicationContext主动获取bean
- POJ 1321
- JDK源码阅读之AbstractList
- Cocos2d-x初学指南(3): 扩展CCAction制作自己的运动轨迹
- 兰亭集序 第一部 逐咒开罗 第十一章 邪瓦
- 李白打酒
- 通过WebApplicationContextUtils工具类获取ApplicationContext对象
- C++文件流输入
- Android——系统权限
- 关于你们所谓的网络聚合,能不能留着原文衔接?
- yii批量插入的方法
- POJ 2676
- jquery validate ajax 验证重复的2种方法
- 初涉江湖
- iOS开发之iOS程序偏好设置(Settings Bundle)的使用