1. 加入 Spring
1). 加入 jar 包
2). 配置 web.xml 文件
3). 加入 Spring 的配置文件.
2. 加入 Hibernate
1). 同时建立持久化类, 和其对应的 .hbm.xml 文件, 生成对应的数据表
2). Spring 整合 Hibernate
3). 步骤:
①. 加入 jar 包
②. 在类路径下加入 hibernate.cfg.xml 文件, 在其中配置 hibernate 的基本属性
③. 建立持久化类, 和其对应的 .hbm.xml 文件
④. 和 Spring 进行整合
i. 加入 c3p0 和 MySQL 的驱动
ii. 在 Spring 的配置文件中配置: 数据源, SessionFactory, 声明式事务
⑤. 启动项目, 会看到生成对应的数据表
3. 加入 Struts2
1). 加入 jar 包: 若有重复的 jar 包, 则需要删除版本较低的. javassist-3.11.0.GA.jar
2). 在 web.xml 文件中配置 Struts2 的 Filter
3). 加入 Struts2 的配置文件
4). 整合 Spring
①. 加入 Struts2 的 Spring 插件的 jar 包
②. 在 Spring 的配置文件中正常配置 Action, 注意 Action 的 scope 为 prototype
③. 在 Struts2 的配置文件中配置 Action 时, class 属性指向该 Action 在 IOC 中的 id
4. 完成功能.
1). 获取所有的员工信息: 若在 Dao 中只查询 Employee 的信息, 而且 Employee 和 Department 还是使用的懒加载. 页面上还需要显示
员工信息, 此时会出现懒加载异常, 代理对象不能被初始化: 2.org.hibernate.LazyInitializationException: could not initialize proxy - no Session
解决:
①. 打开懒加载: 不推荐使用
②. 获取 Employee 时使用 迫切左外连接同时初始化其关联的 Department 对象.
③. 使用 OpenSessionInViewFilter: 后面再提.
2). 删除员工信息:
①. 正常删除, 返回值需要是 redirect 类型, 而且重定向到 emp-list
②. 确定要删除吗? 的提示使用 jQuery 完成
③. Ajax 的使用参见 struts-2.3.15.3-all/struts-2.3.15.3/docs/WW/docs/ajax.html
3). 添加员工:
①. 显示表单页面: 需要先查询所有的部门信息
②. 使用 Struts2 的 ModelDriven 和 Preparable 拦截器
③. 时间是一个字符串, 需要转为一个 Date 类型的对象
没有合适的资源?快使用搜索试试~ 我知道了~
SSH(Struts2+Spring4+Hibernate4)配置及整合
共71个文件
jar:36个
java:9个
xml:8个
4星 · 超过85%的资源 需积分: 9 30 下载量 75 浏览量
2016-09-22
01:23:57
上传
评论 2
收藏 15.74MB ZIP 举报
温馨提示
SSH(Struts2+Spring4+Hibernate4)配置及整合,详细配置过程见http://blog.csdn.net/why_still_confused/article/details/52614636
资源推荐
资源详情
资源评论
收起资源包目录
ssh_test.zip (71个子文件)
ssh_test-master
.gitignore 8B
.project 1KB
.settings
.jsdtscope 503B
org.eclipse.core.resources.prefs 68B
org.eclipse.wst.common.component 554B
org.eclipse.jdt.core.prefs 364B
org.eclipse.wst.common.project.facet.core.xml 345B
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.jsdt.ui.superType.name 6B
conf
xwork-conversion.properties 50B
applicationContext-beans.xml 1KB
db.properties 160B
applicationContext.xml 3KB
struts.xml 1KB
hibernate.cfg.xml 785B
src
com
ssh
actions
EmployeeAction.java 3KB
dao
EmployeeDao.java 930B
DepartmentDao.java 272B
BaseDao.java 371B
entities
Employee.hbm.xml 1KB
Employee.java 1KB
Department.java 396B
Department.hbm.xml 637B
converters
SSHDateConverter.java 831B
service
DepartmentService.java 394B
EmployeeService.java 725B
.springBeans 519B
WebContent
WEB-INF
views
emp-list.jsp 2KB
emp-input.jsp 2KB
web.xml 1007B
lib
commons-lang3-3.1.jar 308KB
jboss-logging-3.1.0.GA.jar 59KB
hibernate-jpa-2.0-api-1.0.1.Final.jar 100KB
ognl-3.0.6.jar 223KB
spring-core-4.0.0.RELEASE.jar 933KB
spring-aspects-4.0.0.RELEASE.jar 50KB
spring-beans-4.0.0.RELEASE.jar 654KB
commons-io-2.0.1.jar 156KB
com.springsource.net.sf.cglib-2.2.0.jar 319KB
spring-tx-4.0.0.RELEASE.jar 242KB
asm-commons-3.3.jar 37KB
spring-aop-4.0.0.RELEASE.jar 343KB
freemarker-2.3.19.jar 909KB
com.springsource.org.aopalliance-1.0.0.jar 5KB
hibernate-core-4.2.4.Final.jar 4.41MB
log4j-1.2.17.jar 478KB
spring-context-4.0.0.RELEASE.jar 928KB
antlr-2.7.7.jar 435KB
spring-orm-4.0.0.RELEASE.jar 309KB
spring-jdbc-4.0.0.RELEASE.jar 410KB
javassist-3.15.0-GA.jar 633KB
c3p0-0.9.1.2.jar 596KB
dom4j-1.6.1.jar 307KB
jboss-transaction-api_1.1_spec-1.0.1.Final.jar 25KB
asm-tree-3.3.jar 21KB
commons-logging-1.1.3.jar 61KB
commons-fileupload-1.3.jar 67KB
spring-web-4.0.0.RELEASE.jar 646KB
xwork-core-2.3.15.3.jar 626KB
struts2-core-2.3.15.3.jar 784KB
com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar 1.57MB
spring-expression-4.0.0.RELEASE.jar 202KB
spring-webmvc-4.0.0.RELEASE.jar 645KB
asm-3.3.jar 43KB
struts2-spring-plugin-2.3.15.3.jar 21KB
hibernate-commons-annotations-4.0.2.Final.jar 80KB
index.jsp 454B
META-INF
MANIFEST.MF 39B
note.txt 2KB
scripts
jquery-1.9.1.min.js 90KB
.classpath 884B
共 71 条
- 1
资源评论
- jasonking12342016-10-21谢谢分享,先收藏再慢慢看
若明天不见
- 粉丝: 1w+
- 资源: 273
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 细胞的奇迹:吃出来的免疫力(美亚畅销书!作者的TED演讲播放量超300万次!《谷物大脑》作者、《三联生活周刊》推荐!吃下对的食物,改善你的... (Z-Library).azw3
- 智能手机产品拆解,使用mindmaster打开
- 11111111111111
- 统信系统ARM64依赖openssl-1.0.2版本的libssl.so.10和libcrypto.so.10文件
- 奥比中光python sdk
- 冯超楠17.py
- OCR识别-基于视觉注意力机制Attention实现的OCR识别算法-附项目源码-优质项目实战.zip
- Java 使用蒙特卡洛方法估算PI的近似值(源代码)
- main.cpp
- 电子木鱼小程序源码电子木鱼小程序源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功