spring bean作用域singleton prototype request session globalsession解读
来源:互联网 发布:电影百万杀人游戏 知乎 编辑:程序博客网 时间:2024/05/29 10:58
spring bean作用域有以下5个:
singleton:单例模式,当spring创建applicationContext容器的时候,spring会欲初始化所有的该作用域实例,加上lazy-init就可以避免预处理;
prototype:原型模式,每次通过getBean获取该bean就会新产生一个实例,创建后spring将不再对其管理;
====下面是在web项目下才用到的===
request:搞web的大家都应该明白request的域了吧,就是每次请求都新产生一个实例,和prototype不同就是创建后,接下来的管理,spring依然在监听
session:每次会话,同上
global session:全局的web域,类似于servlet中的application
注意:当使用request,session,globalsession时需要再web.xml里配置监听器
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
上述配置只支持servlet2.4+版本的,如果低于该版本,容器不支持listener的规范,就要配置成filter的配置方法
filter的具体配置大家自己查吧,filter对应的calss是:org.springframework.web.filter.RequestContextFilter
如果项目采用了springmvc就不需要上面的web.xml的配置了
- spring bean作用域singleton prototype request session globalsession解读
- spring bean作用域singleton prototype request session globalsession解读
- Spring学习历程---request,session与globalSession作用域
- Spring 的作用域 Singleton,Prototype, Session ,Request
- Spring中Bean的作用域singleton, prototype
- spring Bean的作用域(singleton&prototype)
- spring 注解 singleton prototype request session global session
- spring scope注解说明 singleton prototype request session global session
- 《转》详解Spring中bean的scope singleton prototype request...
- Spring 中 bean 的作用域:singleton;prototype;WEB 环境作用域
- Spring容器中Bean的作用域之singleton和prototype
- 使用Spring(七)集合合并、bean的作用域(prototype,singleton)
- spring 当中session或者request作用域注入单例bean的问题
- 10010---bean 的作用域:singleton;prototype;WEB 环境作用域
- 使得任何Bean在Spring IOC容器中可以访问request、session、global Session作用域,RequestContextListener
- spring Singleton-scoped Bean with dependecies on prototype-scoped Bean
- spring中bean的作用域single与prototype区别
- 使用方法注入—协调不同作用域(singleton、prototype)的bean
- 命令式至函數式隨記(三)
- 命令式至函數式隨記(四)
- apache2 module
- 配置
- android activity复杂(计算器)
- spring bean作用域singleton prototype request session globalsession解读
- Android SDK Manager无法安装Android SDK的解决方法
- 黑马程序员_面向对象
- Oracle:EM中设置基于磁盘的备份配置和备份策略
- 活动安排问题(贪心算法)
- sudo ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx
- sql语句大全
- silverlight大数据量录入优化-数据库处理
- 教你用电脑从 Google Play 下载 Android 程序 apk 文件 Favorite