• struts2核心配置之struts.xml


    struts.xml

      -常量配置

      -包配置

      -包含配置

    一、常量配置

    struts2常量的配置通常采用三种方式:

    1、在struts.xml中使用<constant>元素配置常量

    <struts>
        <constant name="struts.i18n.encoding" value="UTF-8"></constant> <!-- 设置默认编码为utf-8 -->
        <constant name="struts.devMode" value="true"></constant> <!-- 设置使用开发模式 -->
    </struts>

    2、在struts.properties文件中配置常量

    3、在web.xml中通过<init-param>配置常量

    二、包配置

    Struts2框架的核心组件是Action和拦截器,它使用包来管理Action和拦截器,每个包就是多个Action,多个拦截器和引用的集合。

    明白了package的地位,就跟我一起来学习学习,come

    package常用属性

    属性 说明 是否必须
    name 指定该包的名字,唯一标识符,此名字是被其他包引用的key
    namespace 该包的命名空间
    extends 继承其他包,可以继承其他包中的Action定义,拦截器定义
    abstract 指定该包是否是一个抽象包

    extends通常设置为struts-default,使该包中的Action具有Struts2框架中的默认拦截器等功能。 

    <package name="TestFirst" namespace="/" extends="struts-default"> 
            <action name="FirstT" class="com.test.pojo.TestAction">
                <result name="success">/success.jsp</result>
            </action>
            <action name="hello" class="com.test.pojo.TestAction" method="hello">
                <result name="hello">/hello.jsp</result>
            </action>
     </package>

    namespace设置为" / "或不写,访问Action路径为项目路径+actionName

    namespace设置为” /* “,访问Action路径为i项目路径+” /* “+actionName

    三、包含配置

    <include>用来在struts.xml中包含其他配置文件

    <include file="struts-HHH.xml"></include>
    <include file="struts-KKK.xml"></include>

    没一个被包含的配置文件都必须是标准的struts配置文件

  • 相关阅读:
    MDL中捕获到损坏的页表页
    跟踪MmSt分页池使用情况
    了解NTFS压缩
    如何跟踪高CPU在用户模式应用程序-现场调试!
    如何与转储文件建立丰富多彩的关系
    Kernel Stack Overflows
    非分页池的消耗
    MBR反汇编
    LPC (Local procedure calls)(二)内核调试扩展
    LPC (Local procedure calls) (一)数据结构
  • 原文地址:https://www.cnblogs.com/GG-Bond/p/10505407.html
Copyright © 2020-2023  润新知