下面給出整合開發時struts 2、 hibernate、spring需要的jar,包太多不打字了,直接截圖。
ps:我資料庫用的是mysql
的配置模版:
<?xml version="1.0" encoding="utf-8"?>
第一步在
spring
中配置資料來源:
第二步整合進
hibernate:
hibernate.dialect=org.hibernate.dialect.mysql5dialect
hibernate.hbm2ddl.auto=update
hibernate.show_sql=false
hibernate.format_sql=false
hibernate.cache.use_second_level_cache=true
hibernate.cache.provider_class=org.hibernate.cache.ehcacheprovider
hibernate.generate_statistics=true
第三步使用
spring
容器管理事務服務:
第四部 配置
hibernate
實體對映檔案city.hbm.xml用myeclipse hibernate的工具即可(前提是先建立好資料庫)。
第五步 在
web容器中使用
listener
例項化spring
容器和配置
struts2
org.springframework.web.context.contextloaderlistener
struts2
org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter
/*
第六步 struts2的配置檔案模版struts.xml如下。常量struts.objectfactory=spring明確指出將由spring負責建立action實 例。
<?xml version="1.0" encoding="utf-8" ?>為了能從/web-inf/page/message.jsp
/web-inf/page/persons.jsp
spring
容器中尋找到
action bean,要求
action
配置的class
屬性值和
spring
中bean
的名稱相同。
第七部 使用
spring
解決struts2
亂碼問題,在web.xml檔案中配置。
encoding
org.springframework.web.filter.characterencodingfilter
encoding
utf-8
/*
第八步
使用spring
解決hibernate
因session
關閉導致的延遲載入例外問題,在web.xml檔案中配置。
opensessioninviewfilter前期配置工作大概就這麼多啦,又完成一篇筆記!org.springframework.orm.hibernate3.support.opensessioninviewfilter
/*
S2SH整合步驟
s2sh 整合步驟 一.搭建開發環境 1.準備三者的 jar檔案 不要忘記相應資料庫的驅動.2.配置web.xml檔案,主要配置兩項內容 1 自動載入 spring 容器的 contextloaderlistener配置 2 應用 struts2 的過濾器 filterdispatcher配置 3....
S2SH無配置詳解
1.hibernate hebernate3.0後可以使用註解自動對映刪除配置檔案,加入的包是hibernate annotations 3.3.1.ga.jar和ejb3 persistence 1.0.1.ga.jar就可以實現 版本可以不同 例子 entity table name airli...
S2SH三者整合方案
注 兩種方案非手動式的。s2sh三者整合方案一 myeclipse blue edition 8.6 第一步 新建乙個web專案,然後為這個專案新增spring能力。第三步 將hibernate的配置資訊配置到spring的配置檔案中,由spring來管理hibernate 重點在於datasour...