zoukankan      html  css  js  c++  java
  • Spring整合Struts2的配置与测试

    • 整合目的

        让Spring的IOC容器管理Struts2的Action

    • 整合步骤

        1、新建一个Web项目

        2、加入Spring的jar包和添加Spring的配置文件

        3、在Web.xml中配置ContextLoadListener

        4、加入Struts2的jar包

        5、在web.xml文件中配置Struts的filter

        6、加入Struts2配置文件

        7、新建Bean,Service和Action类

        8、在Spring配置文件中对Bean,Service和Action类进行配置

        9、配置Struts2的Action为非单例

        10、在Struts2配置文件中配置Action

        11、加入额外的jar包 struts2-spring-plugin-2.3.30.jar

        12、页面测试

    • 示例代码  

        新建一个Web项目

          

        加入Spring的jar包和添加Spring的配置文件

          

          

          

          

        在Web.xml中配置ContextLoadListener

          

          

        加入Struts2的jar包

          

        在web.xml文件中配置Struts的filter

          

          

        加入Struts2配置文件

          

          

        新建Bean,Service和Action类

          

          

          

        在Spring配置文件中对Bean,Service和Action类进行配置

          

        配置Struts2的Action为非单例

          

        在Struts2配置文件中配置Action

          

        加入额外的jar包 struts2-spring-plugin-2.3.30.jar

          

        页面测试

          

          

        测试效果:若能正常显示页面,并且控制台正常输出,则证明Spring的IOC容器被成功创建,Struts2的Action成功被IOC容器管理

          

       

  • 相关阅读:
    Hadoop Yarn 框架原理及运作机制及与MapReduce比较
    模型驱动与属性驱动区别
    spark伪分布式的安装
    大数据集群的常见问题
    linux常用命令
    大数据集群ssh登录其他机器失败 RSA host key for zb03 has changed and you have requested strict checking. Host key verification failed.
    Python 地点转化为经纬度
    Hbase原理、基本概念、基本架构
    struts2的java.lang.NoSuchMethodException错误
    抽象工厂
  • 原文地址:https://www.cnblogs.com/pegasus827/p/9227234.html
Copyright © 2011-2022 走看看