1、新建Web项目,导入包
1)Struts2.2.3.1 http://struts.apache.org/download.cgi#struts2231
需要的Jar包
2)Spring3.0.6 http://www.springsource.org/download
需要的Jar包
org.springframework.web-3.0.6.RELEASE.jar
3)Hibernate3.6.7 http://sourceforge.net/projects/hibernate/files/hibernate3/3.6.7.Final/
需要的Jar包
数据库的jar
oracle mssql mysql
2、配置
1)Web项目的配置:web.xml
struts2 spring
<!-- Spring 配置 Web整合 -->
<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>
<!-- 在Web项目中 启用 Struts2 -->
<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>
2)Struts配置:struts.xml
<!-- Spring和Struts的整合 -->
<constant name="struts.objectFactory" value="spring"></constant>
constant
action
3)Spring配置:applicationContext.xml
bean 依赖注入
hibernate sessionFactory
<!-- 配置 hibernate的SessionFactory -->
<bean id="sessionFactory">
<property name="dataSource" ref="mysqlDataSource"/>
<property name="mappingResources">
<list>
<value>/com/insigma/pojo/Emp.hbm.xml</value>
<value>/com/insigma/pojo/Dept.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQLDialect
show_sql=true
</value>
</property>
</bean>
hibernate配置hibernate.cfg.xml
数据库连接池 dbcp DataBase Connection Pool
<!-- 数据库的连接池配置 -->
<bean id="mysqlDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/test"/>
<property name="username" value="root"/> <property name="password" value="123456"/>
</bean>
oracle mysql mssql db2 sybase
事务管理配置 aop (暂时不配置)
4)Hibernate配置:hibernate.cfg.xml
xxx.hbm.xml
3、搭建项目框架
com.insigma.vo XXXVO.java
com.insigma.utils MD5加密 类型转换
com.insigma.pojo XXX.java XXX.hbm.xml
com.insigma.dao.face IXXXDAO
com.insigma.dao.impl XXXDAOImpl
com.insigma.service.face IXXXService
com.insigma.service.impl XXXServiceImpl
com.insigma.action XXXAction
com.insigma.interceptor XXXInterceptor
src Struts.xml applicationContext.xml hibernate.cfg.xml
web-inf web.xml
web-inf/lib 所有的jar