1.web.xml中配置 struts-config.xml(用于管理action(servlet) 与 actionForm(管理对象属性))

  

<servlet>

  <servlet-name>action</servlet-name>

  <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>

  <init-param>

  <param-name>config</param-name>

  <param-value>/WEB-INF/struts-config.xml</param-value>

  </init-param>

  <init-param>

  <param-name>debug</param-name>

  <param-value>3</param-value>

  </init-param>

  <init-param>

  <param-name>detail</param-name>

  <param-value>3</param-value>

  </init-param>

  <load-on-startup>0</load-on-startup>

 </servlet>

 <servlet-mapping>

  <servlet-name>action</servlet-name>

  <url-pattern>*.do</url-pattern>

</servlet-mapping>

2.web.xml中配置spring的 applicationContext.xml 用于装配业务逻辑

  <servlet>

  <servlet-name>context</servlet-name>

  <servlet-class>

    org.springframework.web.context.ContextLoaderServlet

  </servlet-class>

    <load-on-startup>1</load-on-startup>

  </servlet>

3.struts-config.xml中用代理模式 把 action(servlet) 放到applicationContext.xml中管理

  struts-config.xml中这样改

  

  <controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor"></controller>


  <message-resources parameter="prj23_1.ApplicationResources" />

  <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">

    <set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml" />

  </plug-in>

 

总结:struts 只负责用数据来显示,而spring 用来管理各业务逻辑