SSH:spring,struts2,hibernate.
第一步:整合hibernate的核心包版本号:5.2.12.Final;
配置文件名:hibernate.cfg.xml;
主要内容:数据库连接信息,show_sql,format_sql,关联映射文件
第二步:配置spring
1.applicationContext-public.xml(单例模式)
(1).引入db.properties
(2).配置连接池c3p0
(3).配置sessionFactory
(4).配置事物管理器
(5).配置事物的属性
(6).配置事物的切点
2.applicationContext-dao(单例模式)
3.applicationContext-biz(单例模式)
4.applicationContext-action(原型模式)
第三步:整合struts
注意:struts.xml里的action的属性class对应applicationContext-action.xml里bean的id,而不是class类名
整体:hibernate是交给spring加载,spring,struts由web.xml加载。
1.needed for ContextLoaderListener
2.struts是由filter过滤器加载的;
3.spring是通过listener来加载的;
4.加载services.xml
本文详细介绍了SSH(Spring、Struts2、Hibernate)整合的步骤。首先,配置Hibernate核心包,设定数据库连接信息及映射文件。接着,配置Spring,包括数据库连接池、SessionFactory、事务管理器等。再者,整合Struts2,确保action的class属性与Spring中bean的id匹配。最后,阐述了各组件的加载方式,如Struts通过Filter,Spring通过ContextLoaderListener。
1649

被折叠的 条评论
为什么被折叠?



