日期:2014-05-20 浏览次数:20766 次
<?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:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <!-- 数据源层 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"> </property> <property name="url" value="jdbc:oracle:thin:@Jeelon:1521:fx"></property> <property name="username" value="drp"></property> <property name="password" value="drp"></property> </bean> <!-- SessionFactory层--> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"></property> <property name="configLocation" value="classpath:hibernate.cfg.xml"> </property> </bean> <!-- 事务管理层Biz--> <bean id="tm" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- 事务代理层 定义父类(为了使得多个Biz时不全部写以增加冗余 写出这个父类 下面的只需要几层次代理父类即可 把不同的目标类taret写出即可) --> <bean id="BizProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true" lazy-init="true"> <property name="transactionManager" ref="tm"></property> <property name="transactionAttributes"> <props> <prop key="*">PROPAGATION_REQUIRED</prop> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> </props> </property> </bean> <!-- DAO层--> <bean id="tUserDAO" class="com.jeelon.drp.dao.impl.TUserDAO"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <!-- BIZ层 --> <bean id="tUserBiz" class="com.jeelon.drp.biz.impl.TUserBiz"> <property name="tUserDAO" ref="tUserDAO"></property> </bean> <!-- 继承上面的代理事务 --> <bean id="moduleProxy" parent="BizProxy"> <property name="target" ref="tUserBiz"></property> </bean> <!-- Action层 --> <bean id="UserAction" class="com.jeelon.drp.view.UserAction"> <property name="tUserBiz" ref="moduleProxy"></property> </bean> </beans>
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"> <struts> <!-- 将struts交给spring管理 --> <constant name="struts.objectFactory" value="spring"></constant> <package name="user" extends="struts-default"> <action name="login" class="UserAction"> <result name="success">main.jsp</result> <result name="error">login.jsp</result> </action> </package> </struts>