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

  • 相关阅读:
    【HDOJ6687】Rikka with Stable Marriage(Trie树,贪心)
    【CF1244D】Paint the Tree(树形DP,树)
    【HDOJ6681】Rikka with Cake(扫描线,线段树)
    CPU亲和力
    iostat、vmstat和mpstat命令
    sar命令介绍
    Linux网络调试工具
    svn使用入门
    深入探究C/C++基本数据类型
    core文件与gdb调试
  • 原文地址:https://www.cnblogs.com/junhua4254/p/7686414.html
Copyright © 2011-2022 走看看