Hibernate Dao2:
在DaoImpl中直接注入HibernateTemplate
1.applicationContext.xml中配置HIbernateTemplate
<bean class="...HibernateTemplate "></bean>
2.在DaoImpl中添加HibernateTemplate 屬性
3.使用AutoWired 注入
AOP:AspectOrientedProgram 面向切面編程 oop面向對象編程
粒度:代碼拆分的程度,耦合度
高耦合粗(大)粒度
低耦合細(小)粒度
AOP:AspectOrientedProgram 面向切面編程 目的 爲了實現細粒度,實現對代碼功能無侵入增強
Spring的事務控制
TRUNCATE 和 Delete 的區別 :
TRUNCATE 截斷表 清除主主鍵
Delete 清除,保留主鍵
Spring 整合Struts
Action 的生命週期 :一次請求
請求進來實例化 ,請求結束銷燬
Action 是多例的
1.導包 需要在上一步的 基礎上導入 struts基本jar包
2.Action交由Spring整合
注意Action 是多例的 @Scope("prototype")
web項目中服務啓動時加載spring 配置文件 ,也就是實例化Spring
配置ServletContext初始化參數
ServletContext(Servlet上下文)會在web服務器啓動時會自動實例化
-配置openSessionInview 保證在一次完整請求中,Session不關閉
配置原因:hibernate延遲加載 必須配置在Struts 核心過濾器的上面
1.web.xml中配置監聽器 contextLoadListener (需要寫在覈心配置文件之前)
監聽ServletContext 狀態
2.在web.xml中配置ServletContext初始化參數 spring 配置文件路徑