zoukankan      html  css  js  c++  java
  • Struts2学习-struts+spring

    学习帮助网址:http://www.cnblogs.com/S-E-P/archive/2012/01/18/2325253.html

    http://blog.csdn.net/ad921012/article/details/49679745

     1.配置

    <!-- struts2核心包-core -->
        <dependency>
          <groupId>org.apache.struts</groupId>
          <artifactId>struts2-core</artifactId>
          <version>2.5.13</version>
        </dependency>
    
        <!-- https://mvnrepository.com/artifact/org.apache.struts/struts2-spring-plugin -->
        <dependency>
          <groupId>org.apache.struts</groupId>
          <artifactId>struts2-spring-plugin</artifactId>
          <version>2.5.13</version>
        </dependency>
    
        <!--
    spring-context 包含:core,beans,aop
    注意:没有包含web
     -->
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-context</artifactId>
          <version>5.0.0.RELEASE</version>
        </dependency>
    
        <!--
        spring-core(防止struts降低版本)
         -->
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-core</artifactId>
          <version>5.0.0.RELEASE</version>
        </dependency>
    
        <!--
        spring-beans(防止struts降低版本)
         -->
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-beans</artifactId>
          <version>5.0.0.RELEASE</version>
        </dependency>
    
    
        <!-- spring-web的支持 -->
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-web</artifactId>
          <version>5.0.0.RELEASE</version>
        </dependency>
    View Code
    <!--这一个是spring的监听器-->
      <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:applicationContext.xml</param-value>
      </context-param>
      <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>

    2.我们主要使用resources里的xml文件

    <constant name="struts.objectFactory" value="spring"></constant>
    
    
        <package name="mypackage" extends="struts-default">
            <action name="hello" class="helloAction">
                <result name="success">/WEB-INF/jsp/hello.jsp</result>
            </action>
    
        </package>
    View Code
    <bean id="helloAction" class="com.nf.action.HelloAction">
            <property name="myUser" ref="sUser"></property>
        </bean>
    
        <bean id="sUser" class="com.nf.entity.User">
            <property name="name" value="鹿晗"></property>
            <property name="sex" value="其他"></property>
        </bean>
    View Code

    地址:https://gitee.com/MuNianShi/springweb.git

  • 相关阅读:
    用grunt搭建自动化的web前端开发环境-完整教程
    redis 使用
    ubuntu系统安装redis
    redis resque消息队列
    linux下常用的命令
    介绍Mina的TCP的主要接口(一)
    Mina框架详解——简单的TCPClient
    Mina框架详解——简单的TCPServer
    Mina框架知识解析
    RabbitMQ新手入门Helloworld
  • 原文地址:https://www.cnblogs.com/junhua4254/p/7686414.html
Copyright © 2011-2022 走看看