2014年12月17日. 本文是我自己个人整理的,一步一步教大家怎么配置...
spring3.2.12 hibernate3.6.10 struts2.3.20
虽说hibernate和spring都有4了, 但是最新的不一定就最好的,合适的才是最好的.
我会先配spring,再配hibernate,然后再配struts...(个人感觉springMVC比strtus好用多了)
	
1.先下载各种jar包
http://maven.springframework.org/release/org/springframework/spring/
http://sourceforge.net/projects/hibernate/files/hibernate3/
	
2.导入包
其中还有其它依赖包,,自己百度下载吧
aopalliance.jar
aspectj1.8
commons-logging
mysql-connector-java
....
	
	
2.1导入spring
这个简单.直接把lib所有包都导入就可以了
	    
	
2.2导入hibernate
hibernate3.jar
required/下所有
optional/c3p0
bytecode/*
jpa/*
	
2.3导入struts
这个不要全部导入...这个全部导入会有各种各样的蛋疼错误..
	        
	
3.修改web.xml
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:beans.xml</param-value> </context-param> <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>
	
	
4.创建beans.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:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-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
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations">
			<list>
				<value>classpath:config.propertities</value>
			</list>
		</property>
	</bean>
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
		p:driverClass="${driverClass}" p:maxPoolSize="${maxPoolSize}"
		p:minPoolSize="${minPoolSize}" p:user="${user}" p:password="${password}"
		p:jdbcUrl="${jdbcUrl}" />
	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource"></property>
		<property name="mappingResources">
			<list>
				<value>com/mmeorycat/sshtemplate/entity/User.hbm.xml</value>
			</list>
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.hbm2ddl.auto">update</prop>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
				<prop key="hibernate.show_sql">true</prop>
				<prop key="hibernate.format_sql">true</prop>
			</props>
		</property>
	</bean>
	<bean id="transactionManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
	<tx:annotation-driven />
	<bean id="userDAO" class="com.mmeorycat.sshtemplate.dao.UserDAO">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
	<context:component-scan base-package="com" />
</beans>
5.创建strtus.xml
	
	
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
	<constant name="struts.objectFactory" value="spring" />
	<package name="defaultpack" extends="struts-default">
		<global-results>
			<result>/WEB-INF/content/ok.jsp</result>
			<result name="input">/WEB-INF/content/no.jsp</result>
		</global-results>
		<action name="*">
			<result>/WEB-INF/content/{1}/</result>
		</action>
		<action name="user_register" class="userAction">
			<result>/WEB-INF/content/user/userList.jsp</result>
		</action>
	</package>
</struts>