spring框架中xml檔案常用的屬性配置

2021-09-02 11:48:01 字數 1995 閱讀 3593

!-- 以上就是新增spring開發包後換的乙個頭子,作用就是功能更強大些,就先這麼理解 --

>

<

!-- 常用的屬性配置 --

>

"student"

class

="com.pojo.student"

>

<

!-- 常規屬性 --

>

"stuid" value=

"3">

<

/property>

"stuname" value=

"李四"

>

<

/property>

<

!-- 陣列的配置 --

>

"loves"

>

吃<

/value>

喝<

/value>

玩<

/value>

樂<

/value>

<

/list>

<

/property>

<

!-- map集合的配置 --

>

"others"

>

"age" value=

"18"

>

<

/entry>

"height" value=

"180"

>

<

/entry>

<

/map>

<

/property>

<

/bean>

"studentdao"

class

="com.dao.studentdao"

>

<

/bean>

"studentservice"

class

="com.service.studentservice"

>

<

!-- 屬性值關鍵字 value 和 ref 的區別 --

>

"studentdao" ref=

"studentdao"

>

<

/property>

<

/bean>

<

/beans>這裡對44行注釋部分進行說明;在對示例物件進行初始化的時候,初始化的內容用value和用ref的情況如下:

value: 為屬性設定固定值時用value;

如:

ref: 當屬性本身就是乙個bean(標籤)的時候用 ref

如:

ref裡面的內容要跟上面乙個bean的id的內容一致

Spring框架學習筆記 xml配置

1.dispatcherservlet攔截前段發來的請求 springmvc所有的請求都會通過乙個前段控制器servlet,其任務是將請求傳送給springmvc控制器。一般在web.xml中配置 mvc dispatcher org.springframework.web.servlet.disp...

Spring框架中基於XML的宣告式事務控制

例如 在關聯式資料庫中,乙個事務可以是一條sql語句,一組sql語句或整個程式。原子性 atomicity 乙個事務是乙個不可分割的工作單位,事務中包括的操作要麼都做,要麼都不做。一致性 consistency 事務必須是使資料庫從乙個一致性狀態變到另乙個一致性狀態。一致性與原子性是密切相關的。隔離...

spring中不同環境下在xml檔案中的set注入

就是針對於不同型別的變數,在spring的xml配置檔案中的注入方式。public class user public string getname public void setname string name public hellospring gethellospring public vo...