1.         导入的包

l         struts2的五个基础包:commons-logging-1.1.jar;

freemarker-2.3.8.jar;

ognl-2.6.9.jar;

struts-core-2.0.6.jar;

xwork-2.0.0.jar.

l         spring的核心包:spring.jar

l         二者集成开发所需的包:struts-spring-plugin-2.0.6.jar

2.         修改web.xml配置文件

l         struts2开发所需的分派过滤器及映射所有的action

<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>*.action</url-pattern>   
     </filter-mapping>   

l         配置spring加载上下文时的监听器

<listener>   

<listener-class>

org.springframework.web.context.ContextLoaderListener

</listener-class>   

</listener>   

3.         编写一个action类文件

l         org.yxl.ExampleAction.class:继承自ActionSupport类(注:当加入了struts2.xspring3.x后,会有两个ActionSupport类,这里要选struts2.x中的,即opernsymphony里的)包含一个message属性和覆写execute()方法

4.         配置applicationContext.xml

l         写一个bean

<beans>   
        <bean id=example" class=" org.yxl.ExampleAction "></bean>   
 </beans>  

5.         配置struts.xml

l         定义对象由spring进行产生(整合的关键)

<constant name="objectFactory" value="spring"></constant> 

l         配置Action(class属性的值为4里配置的bean id,不再是类名)[与整合前的区别]

<action name="Example" class=" example ">   
             <result>/show.jsp</result>   
 </action>

6.    OVER