1.导入相应jar包.
2.web.xml配置
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.FilterDispatcher </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping> </web-app>
3.struts.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name = "struts.custom.i18n.resources" value = "messageResoure_zh_CN"/> <constant name="struts.ui.theme" value="simple" /> <constant name="struts.multipart.maxSize" value="41943040" /> <constant name="struts.action.extension" value="action,do,htm" /> <package name="user" extends="struts-default" > <action name="listInfoPar" class="ListInfoParAction"> <result>/Admin/NewsTypeList.jsp</result> </action> <action name="addInfoPar" class="addInfoParAction" > <result name="success" type="redirect">listInfoPar.action</result> </action> <action name="splitPage" class="SplitPageAction"> <result name="back">/Admin/NewsList.jsp</result> <result name="web">/bcview_list.jsp</result> </action> </package> </struts>
4.spring 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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"> </property> <property name="url" value="jdbc:oracle:thin:@192.168.0.119:1521:ubest"> </property> <property name="username" value="oracle"></property> <property name="password" value="oracle"></property> <!-- Connection Pooling Info --> <property name="initialSize" value="5" /> <property name="maxActive" value="100" /> <property name="maxIdle" value="30" /> <property name="maxWait" value="1000" /> <property name="poolPreparedStatements" value="false" /> <property name="defaultAutoCommit" value="true" /> </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="format_sql"> true </prop> </props> </property> <property name="mappingResources"> <list> <value>com/bc/bean/AdminSheet.hbm.xml</value> <value>com/bc/bean/AdInformationSheet.hbm.xml</value> <value> com/bc/bean/InformationParentSheet.hbm.xml </value> <value>com/bc/bean/InformationSheet.hbm.xml</value> <value>com/bc/bean/IntentCustomerSheet.hbm.xml</value> <value>com/bc/bean/PortalSheet.hbm.xml</value> <value>com/bc/bean/PicNewsSheet.hbm.xml</value> </list> </property> </bean> <bean id="Dao" class="com.bc.dao.impl.daoImpl"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <bean id="UserService" class="com.bc.service.impl.userServiceImpl"> <property name="dao"> <ref bean="Dao"/> </property> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <!-- 定义事务管理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="*find*" propagation="NOT_SUPPORTED" read-only="true"/> <tx:method name="*add*" propagation="REQUIRED"/> <tx:method name="*remove*" propagation="REQUIRED"/> <tx:method name="*update*" propagation="REQUIRED"/> </tx:attributes> </tx:advice> <!-- 定义切面 --> <aop:config> <aop:pointcut id="aoppoint" expression="execution(* com.bc.service.impl.userServiceImpl.*.*(..))"/> <aop:advisor advice-ref="txadvice" pointcut-ref="aoppoint"/> </aop:config> <!-- 配置Action --> <bean id="addInfoParAction" class="com.bc.web.AddInfoParAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="ListInfoParAction" class="com.bc.web.ListInfoParAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="ListInfoPar2Action" class="com.bc.web.ListInfoPar2Action" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="RemoveInfoParAction" class="com.bc.web.RemoveInfoParAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="UpdatePInfoParAction" class="com.bc.web.UpdatePInfoParAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="UpdatePInfoAction" class="com.bc.web.UpdatePInfoAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="UpdatePADInfoAction" class="com.bc.web.UpdatePADInfoAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="UpdateInfoParAction" class="com.bc.web.UpdateInfoParAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="UpdateInfoAction" class="com.bc.web.UpdateInfoAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="UpdateRecNewsAction" class="com.bc.web.UpdateRecNewsAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="UpdateHeadlineAction" class="com.bc.web.UpdateHeadlineAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="UpdateADInfoAction" class="com.bc.web.UpdateADInfoAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="AddInfoAction" class="com.bc.web.AddInfoAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="AddADInfoAction" class="com.bc.web.AddADInfoAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="AddIntCustomerAction" class="com.bc.web.AddIntCustomerAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="ListInfoAction" class="com.bc.web.ListInfoAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="ListInfo2BCWebIndexAction" class="com.bc.web.ListInfo2BCWebIndexAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="ListInfoByInfoParId2WebAction" class="com.bc.web.ListInfoByInfoParId2WebAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="ListInfo2PointFamilyAction" class="com.bc.web.ListInfo2PointFamilyAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="ListInfoDetailByIfIdAction" class="com.bc.web.ListInfoDetailByIfIdAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="ListInfo2BCTrendsAction" class="com.bc.web.ListInfo2BCTrendsAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="ListRecNewsAction" class="com.bc.web.ListRecNewsAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="ListHeadlineNewsAction" class="com.bc.web.ListHeadlineNewsAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="ListInfoByInfoParIdAction" class="com.bc.web.ListInfoByInfoParIdAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="ListInfoByInfoParId2BackAction" class="com.bc.web.ListInfoByInfoParId2BackAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="ListADInfoAction" class="com.bc.web.ListADInfoAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="ListIntCustomerAction" class="com.bc.web.ListIntCustomerAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="RemoveInfoAction" class="com.bc.web.RemoveInfoAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="RemoveInfoPictureAction" class="com.bc.web.RemoveInfoPictureAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="RemoveADInfoAction" class="com.bc.web.RemoveADInfoAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="SplitPageAction" class="com.bc.web.SplitPageAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="IsRecAction" class="com.bc.web.IsRecAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="IsHeadAction" class="com.bc.web.IsHeadAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="IsPicAction" class="com.bc.web.IsPicAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="PortalFlashAction" class="com.bc.web.PortalFlashAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="ListFocusNewsAction" class="com.bc.web.ListFocusNewsAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="UpdatePPortalFlashAction" class="com.bc.web.UpdatePPortalFlashAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="UpdatePFocusNewsAction" class="com.bc.web.UpdatePFocusNewsAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="UpdatePortalAction" class="com.bc.web.UpdatePortalAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> <bean id="UpdateFocusAction" class="com.bc.web.UpdateFocusAction" scope="prototype"> <property name="userService"> <ref bean="UserService"/> </property> </bean> </beans>