• Struts2基础


    Struts2不是Struts的升级版,而是Struts技术与webWork技术的结合,都收两者的优势。

    Struts2的配置

    在myeclipse或者eclipse中需要添加相应的架包,IDEA只需要导入相应的配置信息,

    两者中都需要在web.xml配置Struts2的过滤器

    web.xml配置

     <!--Struts2过滤器的配置-->
        <welcome-file-list>
            <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
        <filter>
            <filter-name>struts2</filter-name>
            <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>struts2</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>

    maven项目导入架包如下

    <dependencies>
      <!--struts2包-->
      <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-core</artifactId>
        <version>2.3.24.1</version>
      </dependency>
    </dependencies>

    项目中还需要配置Struts.xm文件,放在web项目的源文件下

    例如:

    <!--声明包-->
    <package name="myPackage" extends="struts-default">
    <!--定义action-->
    <action name="userAction" class="com.lyq.action.UserAction">
    <!--定义处理成功后的映射页面-->
    <result name="add">user_add.jsp</result>
    </action>
    </package>

    package元素的属性:

    name  声明的包名称

    extend 声明继承的包,就是他的父类

    namespace 命名的空间,就是action要访问的路径

    abstract 将包定义为抽象类型 (包中不定义action)

    action元素

    name 配置action对象请求的URL映射

    class 指定action对象的类名

    method 设置请求action对象时,要调用action的哪一个方法

    convert 指定action对象类型的转换器的类

  • 相关阅读:
    Murano为镜像包添加Root用户密码
    Murano Weekly Meeting 2015.09.22
    Murano Weekly Meeting 2015.09.15
    Murano Weekly Meeting 2015.09.08
    Murano Deployment
    Murano Weekly Meeting 2015.09.01
    Murano Application
    Mongodb installation & userguide
    查看linux系统常用的命令,Linux查看系统配置常用命令
    SQL必知必会笔记
  • 原文地址:https://www.cnblogs.com/gun-a/p/10561407.html
Copyright © 2020-2023  润新知