SHH整合概要步骤
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