s2sh整合之xml方式
说明:本文档所采用的框架版本为:Struts 2.1.8, Sping2.5.5, Hibernate 3.5.6
------------Strut2-----------:
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-logging.jar
freemarker-2.3.15.jar
ognl-2.7.3.jar
struts2-core-2.1.8.1.jar
struts2-spring-plugin-2.1.8.1.jar
xwork-core-2.1.6.jar
-------------Spring---------------:
aspectjrt.jar
aspectjweaver.jar
cglib-nodep-2.1_3.jar
common-annotations.jar
commons-lang.jar
commons-logging.jar
spring.jar
-----------Hibernate------------:
antlr-2.7.6.jar
commons-collections-3.1.jar
dom4j-1.6.1.jar
hibernate-annotations.jar
hibernate-commons-annotations.jar
hibernate3.jar
javassist-3.9.0.GA.jar
jta-1.1.jar
slf4j-api-1.5.8.jar
slf4j-log4j12.jar
------------other-----------------
c3p0-0.9.1.2.jar
json-lib-2.1.jar
jstl.jar
junit.jar
log4j-1.2.15.jar
mysql-connector-java-5.1.10-bin.jar
standard.jar
xmlversion="1.0"encoding="UTF-8"?>
<web-appxmlns: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">
<context-param>
<param-name>contextConfigLocationparam-name>
<param-value>classpath:spring/applicationContext.xmlparam-value>
context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListenerlistener-class>
listener>
<filter>
<filter-name>Spring character encoding filterfilter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilterfilter-class>
<init-param>
<param-name>encodingparam-name>
<param-value>UTF-8param-value>
init-param>
filter>
<filter-mapping>
<filter-name>Spring character encoding filterfilter-name>
<url-pattern>/*url-pattern>
filter-mapping>
<filter>
<filter-name>OpenSessionInViewFilterfilter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilterfilter-class>
filter>
<filter-mapping>
<filter-name>OpenSessionInViewFilterfilter-name>
<url-pattern>*.actionurl-pattern>
filter-mapping>
<filter>
<filter-name>struts2filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilterfilter-class>
filter>
<filter-mapping>
<filter-name>struts2filter-name>
<url-pattern>/*url-pattern>
filter-mapping>
<welcome-file-list>
<welcome-file>login.jspwelcome-file>
welcome-file-list>
web-app>
xmlversion="1.0"encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
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-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<beanid="userDao"class="cn.s2sh.demo.dao.impl.UserDaoImpl">
<propertyname="sessionFactory"ref="sessionFactory">property>
bean>
<beanid="userService"class="cn.s2sh.demo.service.impl.UserServiceImpl">
<propertyname="userDao"ref="userDao"/>
bean>
<beanid="userAction"class="cn.s2sh.demo.struts2.action.UserAction"scope="prototype">
<propertyname="userService"ref="userService">property>
bean>
beans>
xmlversion="1.0"encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
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-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<beanid="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<propertyname="configLocation">
<value>classpath:hibernate/hibernate.cfg.xmlvalue>
property>
bean>
<beanid="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<propertyname="sessionFactory">
<refbean="sessionFactory"/>
property>
bean>
<tx:advicetransaction-manager="transactionManager"id="tx">
<tx:attributes>
<tx:methodname="save*"read-only="false"/>
<tx:methodname="delete*"read-only="false"/>
<tx:methodname="update*"read-only="false"/>
<tx:methodname="*"read-only="true"/>
tx:attributes>
tx:advice>
<aop:config>
<aop:pointcutexpression="execution(*cn.s2sh.demo.service.impl.*.*(..))"id="perform"/>
<aop:advisoradvice-ref="tx"pointcut-ref="perform"/>
aop:config>
beans>
xmlversion='1.0'encoding='UTF-8'?>
DOCTYPEhibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<propertyname="dialect">
org.hibernate.dialect.MySQLDialect
property>
<propertyname="connection.url">jdbc:mysql://localhost:3306/s2shdemoproperty>
<propertyname="connection.username">rootproperty>
<propertyname="connection.password">rootproperty>
<propertyname="connection.driver_class">
com.mysql.jdbc.Driver
property>
<propertyname="myeclipse.connection.profile">MySQLproperty>
<propertyname="hbm2ddl.auto">updateproperty>
<propertyname="show_sql">trueproperty>
<mappingresource="cn/s2sh/demo/domain/User.hbm.xml"/>
session-factory>
hibernate-configuration>
xmlversion="1.0"encoding="UTF-8"?>
DOCTYPEstruts PUBLIC
"-//Apache Software Foundation//DTD StrutsConfiguration 2.1.7//EN"
"http://struts.apache.org/dtds/struts-2.1.7.dtd">
<struts>
<constantname="struts.devMode"value="true"/>
<constantname="struts.serve.static.browserCache"value="false"/>
<constantname="struts.ui.theme"value="simple"/>
<constantname="struts.i18n.encoding"value="UTF-8"/>
<constantname="struts.custom.i18n.resources"
value="cn.s2sh.action.token">constant>
<constantname="struts.objectFactory"value="spring"/>
<packagename="user"namespace="/"extends="struts-default">
<actionname="userAction_*"class="userAction"method="{1}">
<resultname="login">login.jspresult>
<resultname="index">index.jspresult>
<resultname="listAction">WEB-INF/jsp/user/list.jspresult>
<resultname="action2action"type="redirectAction">userAction_getAllUserresult>
<resultname="addUI">WEB-INF/jsp/user/saveUI.jspresult>
<resultname="updateUI">WEB-INF/jsp/user/updateUI.jspresult>
action>
package>
struts>
下载完整demo: http://download.csdn.net/detail/rchm8519/7513457