• spring struts 整合


    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 用来管理各业务逻辑

  • 相关阅读:
    linux命令学习笔记(53):route命令
    linux命令学习笔记(52):ifconfig命令
    linux命令学习笔记(51):lsof命令
    linux命令学习笔记(47):iostat命令
    图文并解Word插入修改删除批注
    两步教你生成文档目录
    UML 类图介绍
    win7电脑磁盘文件以分组方式展现解决方案
    jQuery插件开发中$.extend和$.fn.extend辨析
    jquery.fn.extend与jquery.extend
  • 原文地址:https://www.cnblogs.com/sode/p/2693445.html
Copyright © 2020-2023  润新知