SSH整合(struts1)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">

<beans >
	<!-- 1.配置sessionFactory -->
	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
	</bean>
	<!-- 2.配置事务管理器(事务管理器注入sessionFactory)-->
	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFacotry" ref="sessionFactory"></property>
	</bean>
	<!-- 3.配置事务拦截器(事务拦截器注入事务管理器和transactionAttributes过滤条件) -->
	<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
		<property name="transactionManager" ref="transactionManager"></property>
		<property name="transactionAttributes">
			<props>
				<prop key="save*">PROPAGATION_REQUIRED</prop>
				<prop key="update*">PROPAGATION_REQUIRED</prop>
				<prop key="*"></prop>
			</props>
		</property>
	</bean>
	<!-- 4.配置service bean自动代理(注入事务拦截器)(*Service所有的以Service结束的类都自动生成代理对象) -->
	<bean id="autoProxy" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
		<property name="beanNames" value="*Service"></property>
		<property name="interceptorNames" value="transactionInterceptor"></property>
	</bean>
	<!-- 5.配置bean所有的dao bean(dao继承自HibernateDaoSupport,注入sessinFactory)和service bean(注入dao bean)-->
	
	<bean id="studentDao" class="com.aowin.dao.impl.StudentDao">
		<property name="sessionFacotry" ref="sessionFactory"></property>
	</bean>
	<bean id="studentService" class="com.aowin.service.impl.StudentService">
		<property name="studentDao" ref="studentDao"></property>
	</bean>
	<!-- 6.配置action bean(注入service bean,action bean的name与struts-config里的action path属性一一
		   对应,class属性对应实际的action包类路径)-->
	<bean name="/studentlogin" class="com.aowin.action.StudentLoginAction">
		<property name="studentService" ref="studentService"></property>
	</bean>
	<!-- 7.在web.xml中配置监听器,在应用启动或请求某个
	<listener>
  		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  	</listener>
	-->
	<!-- 8.在struts-config配置action,所有action的type属性节点设为:org.springframework.web.struts.DelegatingActionProxy
    	 web容器会在应用启动或者是请求某个action时产生这个action的代理对象
	  	<action input="/index.jsp" path="/login" type="org.springframework.web.struts.DelegatingActionProxy" name="loginForm" validate="true">
	  		<forward name="welcome" path="/welcome.jsp"></forward>
	  		<forward name="fail" path="/index.jsp"></forward>
	  	</action>
	 -->
</beans>
 

猜你喜欢

转载自88548886.iteye.com/blog/1530211
今日推荐