1. WEB.XML first configuration file <! - Spring configuration ->
<listener>
<listener-class> org.springframework.web.context.ContextLoaderListener </ listener-class>
</ listener>
<context-param>
<param-name> contextConfigLocation </ param-name>
<param-value> classpath *: applicationContext *. xml </ param-value>
</ context-param>
<! - Struts2 configuration ->
<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>
</ filter-mapping>
2. Import struts2-spring-plugin-2.1.6.jar package, no need to configure the struts + spring can be integrated using dynamic invocation to the method of ACTION, please configure struts.xml:
<constant name="struts.enable.DynamicMethodInvocation" value="true"> </ constant>
3. ApplicationContext.xml main configuration file:
Tags <beans> now to configure the following attributes ① <beans xmlns = "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/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd ">
② configuration properties file:
<bean>
<property name="locations">
<value> classpath: system.properties </ value>
</ property>
</ bean>
Description: <value> tab classpath: can not be omitted, it represents the type of environment is the root, that is, projects under the SRC directory to find
system.properties document. This is the property of the document properties of configuration information (in accordance with the actual modification of information):
# System Database Config
database.driverClassName = net.sourceforge.jtds.jdbc.Driver
database.connectionString = jdbc: jtds: sqlserver: / / 10.1.0.6:1433 / vendorDoc
database.username = sa
database.password = sql
hibernate.dialect = org.hibernate.dialect.SQLServerDialect
③ Configure SESSIONFACTORY
<bean>
<property name="mappingResources">
<list>
<value> cn / vendordoc / entity / DocRef.hbm.xml </ value>
<value> cn / vendordoc / entity / Staff.hbm.xml </ value>
<value> ...</ value>
</ list>
</ property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.connection.driver_class"> $ (database.driverClassName) </ prop>
<prop key="hibernate.connection.url"> $ (database.connectionString) </ prop>
<prop key="hibernate.connection.username"> $ (database.username) </ prop>
<prop key="hibernate.connection.password"> $ (database.password) </ prop>
<prop key="hibernate.dialect"> $ (hibernate.dialect) </ prop>
<prop key="hibernate.show_sql"> true </ prop>
</ props>
</ property>
</ bean>
④ Configuration Service features:
<tx:advice transaction-manager="transactionManager">
<tx:attributes>
<! - <tx:method Name="execute*" propagation="REQUIRED"/> ->
<tx:method name="*" propagation="REQUIRED"/>
</ tx: attributes>
</ tx: advice>
<! - Those kind of configuration management method ->
<aop:config>
<aop:pointcut expression="execution (* cn.test..*.*(..))"/>







