struts2读取spring中的bean对象
2014-05-08 08:26
281 查看
struts2读取spring中的bean对象:
通过测试:采用IOC/DI注入的效率没有通过getBean获取对象的效率高:
ServletContext sc = ServletActionContext.getServletContext();
if (sc != null) {
WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(sc);
if (wac != null) {
this.xxService = (xxService) wac.getBean("xxService");
if (xxService != null) {
System.out.println("-----ok----");
}
}
} 阅读更多
通过测试:采用IOC/DI注入的效率没有通过getBean获取对象的效率高:
ServletContext sc = ServletActionContext.getServletContext();
if (sc != null) {
WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(sc);
if (wac != null) {
this.xxService = (xxService) wac.getBean("xxService");
if (xxService != null) {
System.out.println("-----ok----");
}
}
} 阅读更多
相关文章推荐
- 使用dom4j:读取spring配置文件,实例化bean对象并注入依赖对象
- Spring读取xml配置文件并加载bean对象
- 使用dom4j:读取spring配置文件,实例化bean对象并注入依赖对象
- struts+spring+hibernate架构中数据对象(PO,POJO,FormBean)的使用心得
- 普通javaBean如何获取到spring托管对象
- spring接口 BeanFactoryAware,动态获取IOC容器里面的对象(多例)
- Spring学习07--Bean对象的初始化(IOC的依赖注入)原理
- Spring基本使用方法_Bean对象
- Spring源码分析:Bean加载流程概览及配置文件读取
- Spring对注解(Annotation)处理源码分析1——扫描和读取Bean定义
- 从spring配置文件中读取bean的方法.txt
- Spring对注解(Annotation)处理源码分析1——扫描和读取Bean定义
- 《step4:tiny-spring-ioc学习四》——读取xml配置来初始化bean
- Spring的IOC、Spring对象初始化bean时机、Spring容器生命周期
- Spring中读取bean配置文件的几种方式
- struts2与spring集成时,关于Action类中成员bean自动注入的问题
- 容器对象spring(4)_ bean属性 scope:作用域和lazy-init
- 获取spring的ApplicationContext和bean对象
- SpringBoot系列四:SpringBoot开发(改变环境属性、读取资源文件、Bean 配置、模版渲染、profile 配置)
- 为什么结合Spring与Struts2的时分,有必要界说Struts2 Bean的Scope