applicationContext.xml文件的配置
<?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"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="http://blog.csdn.net/laukicn/article/details/oracle.jdbc.driver.OracleDriver"> </property> <property name="url" value="http://blog.csdn.net/laukicn/article/details/jdbc:oracle:thin:localhost:1521:orcl"> </property> <property name="username" value="http://blog.csdn.net/laukicn/article/details/demo"></property> <property name="password" value="http://blog.csdn.net/laukicn/article/details/ccce"></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> </props> </property> <property name="mappingResources"> <list> <value>com/pojo/Storage.hbm.xml</value> <value>com/pojo/Orders.hbm.xml</value> <value>com/pojo/OrdersLine.hbm.xml</value> </property></bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="add*" propagation="REQUIRED"/> <tx:method name="delete*" propagation="REQUIRED"/> <tx:method name="update*" propagation="REQUIRED"/> <tx:method name="find*" propagation="NOT_SUPPORTED" read-only="true"/> <tx:method name="get*" propagation="NOT_SUPPORTED" read-only="true"/> <tx:method name="*" propagation="REQUIRED"/> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut expression="execution(public * com.service.impl.*.*(..))" id="pc"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="pc"/> </aop:config> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <bean id="commonDao" class="com.dao.impl.CommonDaoImpl"> <property name="hibernateTemplate"> <ref bean="hibernateTemplate"/> </property> </bean> <bean id="sachDao" class="com.service.impl.SaleService"> <property name="saleCDao"> <ref bean="commonDao"/> </property> <property name="salePlanDao"> <ref bean="commonDao"/> </property> <property name="saleUserDao"> <ref bean="commonDao"/> </property> </bean> <!-- 權限管理 --> <bean id="userDao" class="com.service.impl.UserService"> <property name="userDao"> <ref bean="commonDao"/> </property> </bean> <bean id="rightDao" class="com.service.impl.RightServiceImpl"> <property name="rightDao"> <ref bean="commonDao"/> </property> <property name="roleDao"> <ref bean="commonDao"/> </property> </bean> <!-- 用戶全限 --> <bean id="userActionDao" class="com.action.UserAction" scope="prototype"> <property name="userDao"> <ref bean="userDao"/> </property> <property name="righService"> <ref bean="rightDao"/> </property> </bean> <bean id="roleActionDao" class="com.action.RoleAction" scope="prototype"> <property name="rightService"> <ref bean="rightDao"/> </property> </bean> <bean id="ordeActionDao" class="com.action.OrderAction" scope="prototype"> <property name="orderDao"> <ref bean="ordServiceDao"/> </property> </bean> <bean id="ServiceActionDao" class="com.action.ServiceAction" scope="prototype"> <property name="managerService"> <ref bean="ServManageDao"/> </property> </bean> </beans>Struts2.xml的配置
<?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> <package name="default" namespace="/" extends="json-default"> <!-- 基礎數據 --> <action name="basicAction" class="BasicActionDao"> <result type="json"> <param name="root">dataMap</param> </result> <result name="addB" type="json"> <param name="root">dataMap</param> </result> <result name="delB" type="json"> <param name="root">dataMap</param> </result> <result name="upB" type="json"> <param name="root">dataMap</param> </result> </action> <!-- 用戶管理 --> <action name="userAction" class="userActionDao"> <result type="json"> <param name="root">user</param> </result> <result name="findBy" type="json"> <param name="root">sysuser</param> </result> <result name="updateuse" type="json"> <param name="root">jsonMap</param> </result> <result name="addUs" type="json"> <param name="root">jsonMap</param> </result> <result name="deleu" type="json"> <param name="root">jsonMap</param> </result> </action> <action name="assignTAction" class="userActionDao"> <result type="json"> <param name="root">nodes</param> </result> </action> <action name="righAction" class="userActionDao"> <result type="json"> <param name="root">nodes</param> </result> </action> <action name="roleAction" class="roleActionDao"> <result type="json"> <param name="root">dataMap</param> <param name="excludeProperties"> rows\[\d+\]\.sysRights </param> </result> </action> <action name="updateAction" class="roleActionDao"> <result type="json"> <param name="root">jsonMap</param> </result> <result name="addrol" type="json"> <param name="root">jsonMap</param> </result> <result name="delero" type="json"> <param name="root">jsonMap</param> </result> <result name="roleFind" type="json"> <param name="root">role</param> </result> <result name="upRole" type="json"> <param name="root">jsonMap</param> </result> <result name="upChan" type="json"> <param name="root">salech</param> </result> <result name="fRole" type="json"> <param name="root">rol</param> </result> </action> <action name="usersAction" class="userActionDao"> <result type="json"> <param name="root">dataMap</param> <param name="excludeProperties"> rows\[\d+\]\.sysRole\.sysRights </param> </result> </action> </package> </struts>
web.xml的配置
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <display-name></display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <filter> <filter-name>openSessionInView</filter-name> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> </filter> <filter-mapping> <filter-name>openSessionInView</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>login.jsp</welcome-file> </welcome-file-list> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
Tags: Java
文章來源: