古诗二首_房兵曹胡马_马诗_图文.ppt今天,写一个非常简单的通过struts+hibernate+spring的集成来实现用户登录验证的例子,让大家了解一下三者是如何是整合的。
我们可以通过myeclipse的向导,生成相应的环境搭建,如果使用向导添加SSH项目支持的话,大家记住我们我们添加的顺序为spring,hibernate,struts,我在这儿就不讲如何通过向导添加了,我会直接把源码给大家,大家按源码编写即可。
第一:
<?xml version="" encoding="UTF-8"?>
<beans
xmlns="ema/beans"
xmlns:xsi="1/XMLSchema-instance"
xmlns:aop="ema/aop"
xmlns:tx="ema/tx"
xsi:schemaLocation="ema/beans ema/beans/spring-beans-
ema/aop ema/aop/spring-aop-
ema/tx ema/tx/spring-tx-">
<!-- 定义数据源-->
<bean id="dataSource"
class="">
<property name="driverClassName"
value="">
</property>
<property name="url"
value="jdbc:mysql://:3306/TestDB">
</property>
<property name="username" value="root"></property>
<property name="password" value="hanxue123"></property>
</bean>
<!-- 定义使用hibernate -->
<bean id="sessionFactory"
class="">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="">
</prop>
<prop key="">true</prop>
</props>
</property>
<!-- 定义映射的文件-->
<property name="mappingResources">
<value></value>
</property>
</bean>
<!-- 配置事务管理器-->
<bean id="transactionManager" class="">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<!-- 配置事务的传播特性-->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="find*" propagation="REQUIRED"/>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="modify*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" propagation="REQUIRED
古诗二首 房兵曹胡马 马诗 图文 来自淘豆网www.taodocs.com转载请标明出处.