SSH集成整合

一、Spring配置文件 

<?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"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
	http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
	http://www.springframework.org/schema/aop 
	http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
	http://www.springframework.org/schema/tx 
	http://www.springframework.org/schema/tx/spring-tx-3.0.xsd ">
	<import resource="applicationContext-dao.xml" />
	<import resource="applicationContext-service.xml" />
	<import resource="applicationContext-action.xml" />
	<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:@127.0.0.1:1521:min">
		</property>
		<property name="username" value="CinemaSystem"></property>
		<property name="password" value="CinemaSystem"></property>
	</bean>
	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="dataSource">
			<ref bean="dataSource" />
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">
					org.hibernate.dialect.Oracle9Dialect
				</prop>
				
					<!--<prop key="hibernate.show_sql">true</prop> <prop
					key="hibernate.format_sql">true</prop>
				
			--></props>
		</property>
		<property name="mappingResources">
			<list>
				<value>com/jbit/cinema/entity/Activity.hbm.xml</value>
				<value>com/jbit/cinema/entity/Movie.hbm.xml</value>
				<value>com/jbit/cinema/entity/Orders.hbm.xml</value>
				<value>com/jbit/cinema/entity/Pwdprotect.hbm.xml</value>
				<value>com/jbit/cinema/entity/Timetable.hbm.xml</value>
				<value>com/jbit/cinema/entity/Users.hbm.xml</value>
				<value>com/jbit/cinema/entity/Salle.hbm.xml</value>
				<value>com/jbit/cinema/entity/Seat.hbm.xml</value>
				<value>
					com/jbit/cinema/entity/Onlinecinema.hbm.xml
				</value>
				<value>com/jbit/cinema/entity/Reply.hbm.xml</value>
				<value>com/jbit/cinema/entity/Board.hbm.xml</value>
				<value>com/jbit/cinema/entity/Subject.hbm.xml</value>
			</list>
		</property>
	</bean>
	<!-- 配置Hibernate事务管理器 -->
	<bean id="txManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
	<!-- 配置事务通知 -->
	<tx:advice id="txAdvice" transaction-manager="txManager">
		<tx:attributes>
			<!-- 对get/find/search/query/select开头的方法开启只读事务 -->
			<tx:method name="get*" read-only="true" />
			<tx:method name="find*" read-only="true" />
			<tx:method name="search*" read-only="true" />
			<tx:method name="query*" read-only="true" />
			<tx:method name="select*" read-only="true" />
			<tx:method name="add*" propagation="REQUIRED" />
			<tx:method name="save*" propagation="REQUIRED" />
			<tx:method name="update*" propagation="REQUIRED" />
			<tx:method name="modify*" propagation="REQUIRED" />
			<tx:method name="del*" propagation="REQUIRED" />
			<tx:method name="do*" propagation="REQUIRED" />
			<tx:method name="*" propagation="REQUIRED" read-only="true" />
		</tx:attributes>
	</tx:advice>
	<!--<aop:config>
		 配置切面 -->
	<!--
		<aop:pointcut expression="execution(*
		com.jbit.cinema.service.impl.*.*(..))" id="serviceMethod"/>
	--><!-- 织入 -->
	<!--
		<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethod"/>
		</aop:config>
	-->

	<!-- 配置Dao -->
	<bean id="TimetableDAO" class="com.jbit.cinema.dao.impl.TimetableDaoImpl">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
	<bean id="MovieDAO" class="com.jbit.cinema.dao.impl.MovieDaoImpl">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
	<bean id="PwdprotectDAO" class="com.jbit.cinema.dao.impl.PwdprotectDaoImpl">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
	<bean id="OrdersDAO" class="com.jbit.cinema.dao.impl.OrdersDaoImpl">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
	<bean id="UsersDAO" class="com.jbit.cinema.dao.impl.UsersDaoImpl">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
	<bean id="ActivityDAO" class="com.jbit.cinema.dao.impl.ActivityDaoImpl">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
	<bean id="SeatDAO" class="com.jbit.cinema.dao.impl.SeatDaoImpl">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
	<bean id="SalleDAO" class="com.jbit.cinema.dao.impl.SalleDaoImpl">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
	<bean id="OnlinecinemaDAO" class="com.jbit.cinema.dao.impl.OnlinecinemaDAOImpl">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
	<bean class="com.jbit.cinema.dao.impl.BoardDaoImpl" id="BoardDAO">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
	<bean class="com.jbit.cinema.dao.impl.ReplyDaoImpl" id="ReplyDAO">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
	<bean class="com.jbit.cinema.dao.impl.SubjectDaoImpl" id="SubjectDAO">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>

	<!-- 配置service -->
	<bean id="UsersService" class="com.jbit.cinema.service.impl.UsersServiceImpl">
		<property name="usersDao" ref="UsersDAO" />
		<property name="pwdprotectService" ref="PwdprotectService" />
	</bean>
	<bean id="MovieService" class="com.jbit.cinema.service.impl.MovieServiceImpl">
		<property name="md" ref="MovieDAO" />
	</bean>
	<bean id="ActivityService" class="com.jbit.cinema.service.impl.ActivityServiceImpl">
		<property name="ad" ref="ActivityDAO" />
	</bean>
	<bean id="TimetableService" class="com.jbit.cinema.service.impl.TimetableServiceImpl">
		<property name="td" ref="TimetableDAO" />
	</bean>

	<bean id="PwdprotectService" class="com.jbit.cinema.service.impl.PwdprotectServiceImpl">
		<property name="pwdprotectDao" ref="PwdprotectDAO" />
	</bean>
	<bean id="OnMovieService" class="com.jbit.cinema.service.impl.OnMovieServiceImpl">
		<property name="onMovie" ref="OnlinecinemaDAO" />
	</bean>
	<bean name="SeatService" class="com.jbit.cinema.service.impl.SeatServiceImpl">
		<property name="sd" ref="SeatDAO" />
	</bean>
	<bean name="OrdersService" class="com.jbit.cinema.service.impl.OrdersServiceImpl">
		<property name="od" ref="OrdersDAO" />
	</bean>
	<bean class="com.jbit.cinema.service.impl.BoardServiceImpl" id="BoardService">
		<property name="boardDao" ref="BoardDAO" />
	</bean>
	<bean class="com.jbit.cinema.service.impl.SubjectServiceImpl" id="SubjectService">
		<property name="subjectDao" ref="SubjectDAO" />
		<property name="replyDao" ref="ReplyDAO" />
	</bean>
	<bean class="com.jbit.cinema.service.impl.ReplyServiceImpl" id="ReplyService">
		<property name="replyDao" ref="ReplyDAO" />
	</bean>

	<!-- 配置Action -->
	<bean id="MovieAction" class="com.jbit.cinema.action.MovieAction">
		<property name="ms" ref="MovieService" />
	</bean>

	<bean id="ActivityAction" class="com.jbit.cinema.action.ActivityAction">
		<property name="as" ref="ActivityService" />
	</bean>

	<bean id="TimetableAction" class="com.jbit.cinema.action.TimetableAction">
		<property name="ms" ref="MovieService" />
		<property name="ts" ref="TimetableService" />
	</bean>
	<bean id="onCinemaAction" class="com.jbit.cinema.action.OnMovieAction">
		<property name="onMovieBiz" ref="OnMovieService" />
	</bean>
	<bean name="SeatAction" class="com.jbit.cinema.action.SeatAction">
		<property name="ss" ref="SeatService" />
	</bean>
	<bean name="OrdersAction" class="com.jbit.cinema.action.OrdersAction">
		<property name="os" ref="OrdersService" />
		<property name="ss" ref="SeatService"/>
	</bean>
	<bean class="com.jbit.cinema.action.UsersAction" id="UsersAction">
		<property name="usersService" ref="UsersService" />
		<property name="pwdprotectService" ref="PwdprotectService" />
	</bean>
	<bean class="com.jbit.cinema.action.BoardAction" id="BoardAction">
		<property name="boardService" ref="BoardService" />
	</bean>
	<bean class="com.jbit.cinema.action.SubjectAction" id="SubjectAction">
		<property name="subjectService" ref="SubjectService" />
		<property name="replyService" ref="ReplyService" />
	</bean>
	<bean class="com.jbit.cinema.action.ReplyAction" id="ReplyAction">
		<property name="replyService" ref="ReplyService" />
	</bean>

</beans>

二、hibernate映射文件

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- 
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="com.jbit.cinema.entity.Orders" table="ORDERS" schema="CINEMASYSTEM">
        <id name="id" type="java.lang.Integer">
            <column name="ID" precision="10" scale="0" />
            <generator class="sequence">
               <param name="sequence">SEQ_ORDERS_ID</param>
            </generator>
        </id>
        <property name="UId" type="java.lang.Integer">
            <column name="U_ID" precision="6" scale="0" not-null="true" />
        </property>
        <property name="moviename" type="java.lang.String">
            <column name="MOVIENAME" length="50" not-null="true" />
        </property>
        <property name="pid" type="java.lang.Integer">
            <column name="PID" precision="6" scale="0" not-null="true" />
        </property>
        <property name="count" type="java.lang.Integer">
            <column name="COUNT" precision="6" scale="0" not-null="true" />
        </property>
        <property name="payWay" type="java.lang.String">
            <column name="PAY_WAY" length="20" not-null="true" />
        </property>
        <property name="placeNumber" type="java.lang.String">
            <column name="PLACE_NUMBER" length="200" not-null="true" />
        </property>
        <property name="totalMoney" type="java.lang.Integer">
            <column name="TOTAL_MONEY" precision="6" scale="0" not-null="true" />
        </property>
        <property name="reserveIme" type="java.util.Date">
            <column name="RESERVE_IME" length="7" not-null="true" />
        </property>
    </class>
</hibernate-mapping>

三、struts2配置文件

<?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>
	<constant name="struts.il8n.encoding" value="UTF-8" />
	<package name="json" namespace="/" extends="json-default">
		<action name="CheckUserName" class="UsersAction" method="checkUserName">
			<result type="json">
				<param name="root">result</param>
			</result>
		</action>
	</package>
	<package name="default" namespace="/" extends="struts-default">
		<!-- 定义拦截器组 -->
		<interceptors>
			<!-- 定义权限拦截的应用类 -->
			<interceptor name="myAuthor"
				class="com.jbit.cinema.interceptor.AuthorInterceptor">
				<!-- 定义需要拦截的方法 -->
				<param name="includeMethods">addR,addS,updatePwd,updateProblem,loadProtect,getOne,book_ticket</param>
			</interceptor>
			<!-- 定义拦截器栈 -->
			
			<interceptor-stack name="myStack">
				<interceptor-ref name="defaultStack" />
				<interceptor-ref name="myAuthor" />
			</interceptor-stack>
		</interceptors>
		<!-- 定义默认拦截器栈 -->
		<default-interceptor-ref name="myStack" />
		<!-- 定义全局结果 -->
		
		<global-results>
			<result name="login">member_center.jsp</result>
		</global-results>
		<!--配置用户Action以及method -->
		
		<action name="*User" method="{1}" class="UsersAction">
			<result name="success" type="redirect">${nextDispose}</result>
			<result name="input" type="redirect">${nextDispose}</result>
		</action>
		<!-- 配置版块Action以及method -->
		
		<action name="*Board" method="{1}" class="BoardAction">
			<result name="success" type="redirect">${nextDispose}</result>
			<result name="input" type="redirect">${nextDispose}</result>
		</action>
		<!-- 配置主题Action以及method -->
		
		<action name="*Subject" method="{1}" class="SubjectAction">
			<result name="success" type="redirectAction">${nextDispose}</result>
			<result name="input" type="redirect">${nextDispose}</result>
		</action>
		<!-- 配置回复Action以及method -->
		
		<action name="*Reply" method="{1}" class="ReplyAction">
			<result name="success" type="redirectAction">${nextDispose}</result>
			<result name="input" type="redirect">${nextDispose}</result>
		</action>
		<action name="*movie" class="MovieAction" method="{1}">
			<result name="save" type="redirectAction">getmovie</result>
			<result name="success">index.jsp</result>
			<result name="fenye">${nextPage}</result>
			<result name="findMovie">movieinfo.jsp</result>
			<result name="error">error.jsp</result>
		</action>
		<action name="*activity" class="ActivityAction" method="{1}">
			<result name="success" type="redirectAction">getmovie</result>
			<result name="findAll">filmMovement.jsp</result>
			<result name="findOne">ActivtiyInfo.jsp</result>
			<result name="type">activity.jsp</result>
			<result name="error">error.jsp</result>
		</action>
		<action name="*timetable" class="TimetableAction" method="{1}">
			<result name="success" type="redirectAction">getmovie</result>
			<result name="findAll">${nextPage}</result>
			<result name="getOne">ticketing_step2.jsp</result>
			<result name="error">error.jsp</result>
		</action>
		<action name="*onMovie" class="onCinemaAction" method="{1}">
			<result name="success">${nextPage}</result>
		</action>
		<action name="*Seat" class="SeatAction" method="{1}">
			<result name="findAll">ticketing_step4.jsp</result>
		</action>
		<action name="*Orders" class="OrdersAction" method="{1}">
			<result name="save" type="redirect">ticketing_step5.jsp</result>
		</action>
	</package>
</struts>    

猜你喜欢

转载自x125858805.iteye.com/blog/1633413