SSH的整合
1. 添加三个框架的Jar包
2. 添加Spring的配置文件:
根据四层结构分类配置:
applicationContext-web.xml 添加Struts1的Action的配置
applicationContext-service.xml 添加业务逻辑类的配置以及声明式事务的配置
applicationContext-dao.xml 添加数据源、SessionFactory以及Dao的配置
3. 添加Hibernate的配置文件(可选的)
在hibernate配置文件中添加:数据库方言的配置和ORM映射配置。
4. 添加Struts的配置文件:
在web.xml中添加ActionServlet的配置,在struts-config.xml中添加Form,Action的配置
5. Spring整合Hibernate:使用Spring提供的LocalSessionFactoryBean或AnnoationSessionFactoryBean作为Hibernate的SessionFactory
6. Spring整合Struts1:
1) 在web.xml中添加ContextLoaderListener来在部署本Web应用就初始化好WebApplicationContext实例。
通过<context-param>告诉Listener,Spring的配置文件的位置。
2) 在Struts配置文件中,把它默认的请求处理器更换成Spring提供的DalegatingRequestProcessor类。
3) 针对Struts1中的每个Action配置在对应的Spring配置文件要配置一个别名与path相同的Action类。
7. Spring针对Hibernate提供了OSIV过滤器。OpenSessionInViewFilter
8. Spring针对Web应用提供了请求数据编码过滤器。CharacterEncodingFilter