`
hylxinlang
  • 浏览: 125127 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

spring笔记1

阅读更多

名词解释

一。ioc(inverse of controll ) 控制反转: 所谓控制反转就是把创建对象(bean),和维护对象(bean)的关系的权利从程序中转移到spring的容器(applicationContext.xml),而程序本身不再维护.

二。 di(dependency injection) 依赖注入: 实际上diioc是同一个概念,spring设计者认为di更准确表示spring核心技术

bean作用域

scope=""

 

作用域 描述

singleton

在每个Spring IoC容器中一个bean定义对应一个对象实例。

prototype

一个bean定义对应多个对象实例。

request

在一次HTTP请求中,一个bean定义对应一个实例;即每次HTTP请求将会有各自的bean实例, 它们依据某个bean定义创建而成。该作用域仅在基于web的Spring ApplicationContext情形下有效。

session

在一个HTTP Session中,一个bean定义对应一个实例。该作用域仅在基于web的Spring ApplicationContext情形下有效。

global session

在一个全局的HTTP Session中,一个bean定义对应一个实例。典型情况下,仅在使用portlet context的时候有效。该作用域仅在基于web的Spring ApplicationContext情形下有效。

<bean id="changeLetter" class="cn.hyl.hsp.inter.UpperLetter" scope="singleton">

<property name="str" value="ABRTY"  />

</bean>

 

<!--[if !supportLists]-->u  <!--[endif]-->三种获取ApplicationContext 对象引用的方法

<!--[if !supportLists]-->1.       <!--[endif]-->ClassPathXmlApplicationContext -> 通过类路径

<!--[if !supportLists]-->2.       <!--[endif]-->FileSystemXmlApplicationContext -> 通过文件路径

举例:

ApplicationContext ac=new FileSystemXmlApplicationContext("文件路径beans.xml / applicationContext.xml");

 

<!--[if !supportLists]-->3.       <!--[endif]-->XmlWebApplicationContext

0
4
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics