1.1.  Spring综合Struts2

1)        该Spring用户手机WEB-INF下一个

Spring综合Struts2_spring配置

2)        把Spring配置文件配置到web.xml中


         <!-- 引入Spring配置文件 -->

         <context-param>

                   <param-name>contextConfigLocation</param-name>

                   <param-value>/WEB-INF/applicationContext.xml</param-value>

         </context-param>


3)        在web.xml中配置Spring监听


         <!-- Spring监听器 -->

         <listener>         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

         </listener>


4)        在Spring配置文件里配置Struts2的Action


<bean id="userAction" class="com.morris.spring.action.UserAction">

         </bean>


5)        在Struts2的配置文件里引入spring常量


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


6)        在Struts2的配置文件里配置Action,class为在Spring中配置的id值


<package name="default" extends="struts-default" namespace="/">

                   <action name="welcome" class="userAction" method="welcome">

                            <result>/index.jsp</result>

                   </action>

         </package>