java ssh 整合_java ssh整合的步骤

首先创建一个web工程就不用多说了,直接进入整合阶段。

第一步:加入Spring

1)首先导入Spring的jar包,解压spring-framework-4.0.1.RELEASE-dist压缩包,里面的lib文件夹全部导入

2)配置web.xml文件

org.springframework.web.context.ContextLoaderListener

contextConfigLocation

classpath:applicationContext*.xml

3)加入Spring的配置文件: applicationContext.xml

第二步:加入hibernate

1)加入hibernate jar包

解压hibernate-release-4.2.4,文件夹\lib\required的全部文件

2)在类路径下加入hibernate.cfg.xml文件,在其中配置hibernate的基本属性

update

true

true

org.hibernate.dialect.MySQL5Dialect

3)建立持久化类,和其对应的.hbm.xml文件,生成对应的数据表

4)和spring进行整合

1.加入c3p0和MySQL的驱动

2.在applicationContext.xml文件里面配置:数据源,SessionFactory,声明式事务

3.启动项目,会在数据库看到对应的数据表

第三步:加入hibernate

1)加入jar包:解压struts-2.3.35  里面的apps\lib文件夹导入

2)在web.xml文件中配置Struts的Filter

struts2

org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

struts2

/*

3)加入Struts.xml文件(配置Action)

4)   整合spring :struts-2.3.35里面的lib文件夹(重复的删掉,版本低的删掉)

5)在Spring的配置文件里面配置Action时,Action的scope 的属性为prototype

6)在 Struts2 的配置文件Struts.xml中配置 Action 时, class 属性指向该 Action 在 IOC(applicationContext.xml) 中的 id

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值