
這是比較重要的:
+++++++++++++spring整合hibernate:
首先,将會話工廠整合了
其次将食物的開啟和關閉也整合了。
為什麼要在業務層中加入事務:因為在實際的項目中,業務是相對來說比較複雜的,有時候要通路很多次資料庫,很有可能是通路不同的資料庫,會對資料的完整性造成影響,這是時候就需要使用事務。
聲明式事務的核心問題是:對哪些方法,采取什麼樣的事務政策。
配置步驟:
導入tx,和aop命名空間
配置事務管理器,并且為其注入sessionFactory,
基于該事務管理器配置事務增強,指定事務規則
配置切面, 定義切入點,織入事務切面
在使用oracle資料庫的時候應該注意的問題:
注意:這兩個序列的名字應該是一樣的。
注意:是在添加不進去資料的時候,偷懶的辦法,将資料庫中的表中的字段設定為nullable,就能夠添加進去資料了,同樣主鍵也能夠自動生成出來。
+++++++++++++++spring與struts2的繼承+++++++++++++++++++++
注意:這裡的action的執行個體還是有struts2建立的,業務bean如何注入給action,是通過spring容器注入的。
在web.xml檔案中監聽器是最先被執行的。
這個jar檔案很重要。
這是web.xml檔案中需要配置的東西:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!--指定spring的配置檔案 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!-- 配置監聽器 啟動spring 容器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 配置延遲加載 這裡可以不用配置,但是一般情況下是建議配置上的-->
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<!--配置struts2本身就需要的過濾器 -->
<filter-name>Struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<url-pattern>/*</url-pattern><!--表示所有的請求都由struts架構來進行處理 -->
</web-app>
注意:由于自己的粗心,一定要注意使用者和密碼,一定要輸入正确。
struts2和spring內建的第二種方式
這種方式一般情況下不怎麼用,因為會增加複雜度.
注意:第一種方式和第二種方式是能夠同時存在的
spring 中bean的作用域
*使用注解實作ssh的內建
目的:解決在spring配置檔案中的代碼量