1.导包——参照我的GitHub
Hibernate
hibernate/lib/required
hibernate/lib/jpa
数据库驱动
Struts2
struts-blank.war/WEB-INF/lib/*
struts整合spring插件包(一旦导入,一定要启动Spring容器)
Spring
基本4+2
整合web:web包
整合aop:4个
整合jdbc事务:3个
junit测试:test包
2.单独配置Spring容器
创建配置文件,导入约束
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans" 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-4.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd "> </beans>
配置监听器
3.单独配置Struts2
配置sturts.xml
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <package name="crm" namespace="/" extends="struts-default"> <action name="UserAction_*" class="com.littlepage.web.action.UserAction" method="{1}"> <result name="success">/</result> </action> </package> </struts>
创建action
配置过滤器到web.xml
4.整合Struts2和Spring
导包
配置常量struts.xml(将action的创建交给spring容器)
<constant name="struts.objectFactory" value="spring"></constant>