SSH整合实例.docx

上传人:b****2 文档编号:18185700 上传时间:2023-04-24 格式:DOCX 页数:35 大小:25.21KB
下载 相关 举报
SSH整合实例.docx_第1页
第1页 / 共35页
SSH整合实例.docx_第2页
第2页 / 共35页
SSH整合实例.docx_第3页
第3页 / 共35页
SSH整合实例.docx_第4页
第4页 / 共35页
SSH整合实例.docx_第5页
第5页 / 共35页
点击查看更多>>
下载资源
资源描述

SSH整合实例.docx

《SSH整合实例.docx》由会员分享,可在线阅读,更多相关《SSH整合实例.docx(35页珍藏版)》请在冰豆网上搜索。

SSH整合实例.docx

SSH整合实例

Struts、Spring、Hibernate(SSH)整合实例

关键字:

struts、spring、hibernate(ssh)整合实例

首选创建web.xml主要是配置Struts的ActionServlet和Spring的字符过滤器

Xml代码

1.

xml version="1.0" encoding="UTF-8"?

>  

2.

xsi="http:

//www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:

schemaLocation="     

3.   

4.    

5.    CharacterEncodingFilter  

6.    org.springframework.web.filter.CharacterEncodingFilter  

7.      

8.      encoding  

9.      UTF-8  

10.      

11.      

12.      forceEncoding  

13.      true  

14.      

15.    

16.   

17.    

18.    CharacterEncodingFilter  

19.    /*  

20.    

21.   

22.    

23.    action  

24.    org.apache.struts.action.ActionServlet  

25.      

26.      config  

27.      /WEB-INF/struts/struts.xml  

28.      

29.      

30.      debug  

31.      3  

32.      

33.      

34.      detail  

35.      3  

36.      

37.    0  

38.    

39.   

40.    

41.    action  

42.    *.do  

43.    

44.   

45.  

-- session超时定义,单位为分钟 -->  

46.    

47.    10  

48.    

49.   

50.  

-- 默认首页定义 -->  

51.    

52.    index.jsp  

53.    index.html  

54.    

55.   

56.  

xmlversion="1.0"encoding="UTF-8"?

>

xsi="http:

//www.w3.org/2001/XMLSchema-instance"version="2.4"xsi:

schemaLocation="

CharacterEncodingFilter

org.springframework.web.filter.CharacterEncodingFilter

encoding

UTF-8

forceEncoding

true

CharacterEncodingFilter

/*

action

org.apache.struts.action.ActionServlet

config

/WEB-INF/struts/struts.xml

debug

3

detail

3

0

action

*.do

--session超时定义,单位为分钟-->

10

--默认首页定义-->

index.jsp

index.html

然后创建struts.xml(String配置文件)要注意这里集成了Spring插件,把全部Spring配置文件注入到ContextLoaderPlugIn中

Xml代码

1.

xml version="1.0" encoding="UTF-8"?

>  

2.

DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http:

//struts.apache.org/dtds/struts-config_1_2.dtd">  

3.  

4.  

5.    

6.   

7.    

8.  

9.    

10.     

11.    

12.  

13.    

14.   

15.     name="loginVO"  

16.      type="org.springframework.web.struts.DelegatingActionProxy"  

17.      parameter="action"  

18.      scope="request">  

19.        

20.        

21.      

22.    

23.  

24.  

-- 集成Spring插件 -->  

25.    

26.      

27.    

28.  

29.  

xmlversion="1.0"encoding="UTF-8"?

>

DOCTYPEstruts-configPUBLIC"-//ApacheSoftwareFoundation//DTDStrutsConfiguration1.2//EN""http:

//struts.apache.org/dtds/struts-config_1_2.dtd">

name="loginVO"

type="org.springframework.web.struts.DelegatingActionProxy"

parameter="action"

scope="request">

--集成Spring插件-->

配置Spring配置文件

Xml代码

1.

xml version="1.0" encoding="UTF-8"?

>  

2.

DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http:

//www.springframework.org/dtd/spring-beans.dtd">  

3.  

4. 

-- 读入属性文件 -->  

5.   

6.    

7.     

8.    classpath:

hibernate.properties  

9.     

10.    

11.   

12.  

13. 

-- 配置数据源,可以其他方式 -->  

14.   

15.       

16.    

17.    

18.    

19.       

20.    

21.    

22.      

23.  

24. 

-- 配置Hibernate的Session工厂,注入数据源、映射文件 -->  

25.      

26.       

27.          

28.       

29.          

30.              

31.                com/po/login.hbm.xml  

32.              

33.          

34.          

35.         

36.         ${hibernate.dialect}  

37.         ${hibernate.showSQL}  

38.         

39.       

40.      

41.  

42. 

-- 声明Hibernate事务管理,注入Session工厂 -->  

43.      

44.       

45.         

46.       

47.     

48.  

49. 

-- 配置事务代理,注入事务管理transactionManager,由Spring来代理事务,设置事务属性 -->  

50.      

51.       

52.         

53.       

54.       

55.         

56.           PROPAGATION_REQUIRED,-Exception  

57.               PROPAGATION_REQUIRED,-Exception  

58.               PROPAGATION_REQUIRED,-Exception  

59.               PROPAGATION_REQUIRED,-Exception  

60.               PROPAGATION_REQUIRED,-Exception  

61.               PROPAGATION_REQUIRED,-Exception  

62.               PROPAGATION_REQUIRED,readOnly  

63.               PROPAGATION_REQUIRED,readOnly  

64.               PROPAGATION_REQUIRED,readOnly  

65.               PROPAGATION_REQUIRED,readOnly  

66.               PROPAGATION_REQUIRED  

67.         

68.       

69.      

70.  

xmlversion="1.0"encoding="UTF-8"?

>

DOCTYPEbeansPUBLIC"-//SPRING//DTDBEAN//EN""http:

//www.springframework.org/dtd/spring-beans.dtd">

--读入属性文件-->

classpath:

hibernate.properties

--配置数据源,可以其他方式-->

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1