如何整合ssh三大框架

怎么整合ssh三大框架
我学完了struts2  hibernate  spring  就是不知道怎么整合  求高人赐教
------解决方案--------------------
你搞清楚他们在一起使用的时候各自发挥的功能吧,具体整合一块只是配置问题了,主要是理解SSH的优势
------解决方案--------------------
这个真的不是一下子给说清楚的。网上确实有很多这方面的介绍。你去下载看看吧。步骤来说:
1,是包加入
2,配置好
3,测试一下。
这些步骤最复杂的应该是配置。
如果你用高版本的注解可能会省很多配置方便很多。
------解决方案--------------------
spring主要用来依赖注入,比如把DAO注入到service,spring还用来进行事务管理。
hibernate当然是负责数据库的操作,增删改查。。。
strtus2是实现MVC的框架,和web打交道,页面参数的获取,验证,以及跳转页面等...
------解决方案--------------------
第一步:导入SSH相关jar包和数据库jar包
第二步:编写配置文件
1. 编写sping配置文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-2.5.xsd
           http://www.springframework.org/schema/tx
           http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

<!-- 对受管组件Classpath进行扫描 -->
<context:component-scan base-package="com.sls" />

<!-- 配置属性占位符配置器   即读取配置文件的数据库连接文件 location这个是定值-->
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>classpath:jdbc.properties</value>
</property>
</bean>

<!-- 配置数据库源 -->
<bean id="dataSource" destroy-method="close"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>


<!--
配置Hibernate实现的AnnotationSessionFactory工厂,本工厂在系统运行期间只产生一个SessionFactory实例
-->
<bean
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
id="sessionFactory">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
<!-- 配置包扫描 针对的是使用了JPA注解的实体类的 -->
<property name="packagesToScan">
<list>
<value>com.sls.entity</value>
</list>
</property>
</bean>

<!-- 配置HibernateTemplate以简化Hibernate应用的开发即Hibernate模版-->
<bean class="org.springframework.orm.hibernate3.HibernateTemplate"
id="hibernateTemplate">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<!-- 配置事务管理器 -->
<bean id="txManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<!-- 使用基于注解方式配置事务 -->
<tx:annotation-driven transaction-manager="txManager" />

</beans>
2.编写jdbc.properties
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/myDataBase
jdbc.username=root
jdbc.password=root
3.编写Struts2.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>
<!-- 与spring集成时,指定由spring负责action对象的创建 -->
<constant name="struts.objectFactory" value="spring"></constant>
<constant name="struts.devMode" value="false" />
<package name="employee" extends="struts-default" namespace="/employee">
<action name="list" class="employeeAction">
<result name="list">/list.jsp</result>
</action>
</package>
</struts>
4. 编写web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<!-- 扫描器 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:beans.xml</param-value>