`

struts.xml配置文件详解

阅读更多
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd" > 
<struts> 
 
    <!-- include节点是struts2中组件化的方式 可以将每个功能模块独立到一个xml配置文件中 然后用include节点引用 --> 
    <include file="struts-default.xml"></include> 
      
      
    <!-- package提供了将多个Action组织为一个模块的方式  
        package的名字必须是唯一的 package可以扩展 当一个package扩展自  
        另一个package时该package会在本身配置的基础上加入扩展的package  
        的配置 父package必须在子package前配置   
        name:package名称  
        extends:继承的父package名称  
        abstract:设置package的属性为抽象的 抽象的package不能定义action 值true:false  
        namespace:定义package命名空间 该命名空间影响到url的地址,例如此命名空间为/test那么访问是的地址为http://localhost:8080/struts2/test/XX.action  
     --> 
    <package name="com.kay.struts2" extends="struts-default" namespace="/test"> 
        <interceptors> 
            <!-- 定义拦截器   
                name:拦截器名称  
                class:拦截器类路径  
             --> 
            <interceptor name="timer" class="com.kay.timer"></interceptor> 
            <interceptor name="logger" class="com.kay.logger"></interceptor> 
            <!-- 定义拦截器栈 --> 
            <interceptor-stack name="mystack"> 
                <interceptor-ref name="timer"></interceptor-ref> 
                <interceptor-ref name="logger"></interceptor-ref> 
            </interceptor-stack> 
        </interceptors> 
          
        <!-- 定义默认的拦截器 每个Action都会自动引用  
         如果Action中引用了其它的拦截器 默认的拦截器将无效 --> 
        <default-interceptor-ref name="mystack"></default-interceptor-ref> 
          
          
        <!-- 全局results配置 --> 
        <global-results> 
            <result name="input">/error.jsp</result> 
        </global-results> 
          
        <!-- Action配置 一个Action可以被多次映射(只要action配置中的name不同)  
             name:action名称  
             class: 对应的类的路径  
             method: 调用Action中的方法名  
        --> 
        <action name="hello" class="com.kay.struts2.Action.LoginAction"> 
            <!-- 引用拦截器  
                name:拦截器名称或拦截器栈名称  
             --> 
            <interceptor-ref name="timer"></interceptor-ref> 
          
            <!-- 节点配置  
                name : result名称 和Action中返回的值相同  
                type : result类型 不写则选用superpackage的type struts-default.xml中的默认为dispatcher  
             --> 
         <result name="success" type="dispatcher">/talk.jsp</result> 
         <!-- 参数设置   
             name:对应Action中的get/set方法   
         --> 
         <param name="url">http://www.sina.com</param> 
        </action> 
    </package> 
</struts> 
0
1
分享到:
评论

相关推荐

    Struts2中Struts.xml配置文件详解

    "Struts2 中 Struts.xml 配置文件详解" Struts2 中的 Struts.xml 配置文件是 Struts2 框架的核心配置文件,用于定义应用程序的行为和结构。在 Struts.xml 文件中,我们可以定义 package、action、interceptor、...

    struts2.0中struts.xml配置文件详解

    在深入探讨Struts2.0框架中的`struts.xml`配置文件之前,我们先来了解一下Struts2.0框架的基本概念。Struts2是Apache软件基金会的一个开源项目,它是一个基于MVC(Model-View-Controller)设计模式的Java Web应用...

    struts.xml和struts.properties配置详解

    在Struts中,`struts.xml`和`struts.properties`文件是两个核心的配置文件,它们分别负责定义应用的行为和设置全局属性。 **`struts.xml`配置详解** `struts.xml`是Struts 2框架的核心配置文件,用于定义动作映射...

    struts.xml文件详解.doc

    Struts.xml文件是Apache Struts 2框架的核心配置文件,它用于定义应用程序的行为、Action映射、结果页面、拦截器等关键组件。在深入讲解struts.xml之前,我们先来了解与之相关的struts.properties文件。 struts....

    web.xml配置文件详解

    ### web.xml配置文件详解 #### 一、概述 `web.xml`是Java Web应用程序的核心配置文件之一,主要用于定义Web应用程序的结构与行为。它是Servlet容器(如Tomcat)读取Web应用程序配置信息的主要来源,因此深入理解其...

    struts2的struts.properties配置文件详解

    Struts2的Struts.properties配置文件详解 Struts2是一个基于MVC模式的Web应用程序框架,它提供了一个名为Struts.properties的配置文件,该文件用于配置Struts2的各种参数和设置。下面将对Struts.properties配置文件...

    struts.xml配置详解

    比如在大型项目中,可以将用户管理、商品管理和订单管理等不同的功能模块分别配置在不同的xml文件中(如user.xml、goods.xml和order.xml),然后通过struts.xml中的标签将这些模块配置文件引入主配置文件中。...

    struts.xml文件详解示例代码

    Struts.xml文件是Apache Struts 2框架的核心配置文件,用于定义应用的MVC(Model-View-Controller)架构和动作映射。它为应用程序提供了一种声明式的方式来配置Struts2的行为,使得开发者能够控制请求如何被处理,...

    struts-config.xml配置文件详解

    Struts-config.xml 配置文件详解 Struts-config.xml 是 Struts 框架的主要配置文件,用于配置 Struts 应用程序的各种设置。在该文件中,可以配置数据源、Form Bean、Action 和插件等信息。下面是 Struts-config.xml...

    Struts课堂笔记.rar--struts2的struts.properties配置文件详解

    struts自动加载的一个配置文件列表 struts.configuration.xml.reload Whether to reload the XML configuration or not 是否加载xml配置(true,false) struts.continuations.package The package containing ...

    Struts框架中struts-config.xml文件配置小结

    而在Struts框架中,`struts-config.xml`文件扮演着至关重要的角色,它是Struts框架的核心配置文件,用于配置应用程序的各种行为和组件。本文将对`struts-config.xml`中的关键元素进行详细解析,并结合实际示例来帮助...

    Struts-config.xml配置详解

    Struts的配置文件通常命名为struts-config.xml,它是整个Struts应用的核心配置文件,通过定义一系列的XML元素来设定框架的不同功能和行为。下面将详细介绍struts-config.xml中8个主要配置元素的功能和使用方法。 1....

    struts1中web.xml配置详解

    在 struts1 框架中,web.xml 文件是必不可少的配置文件之一,它用于配置 Struts 应用程序的核心组件 ActionServlet。本文将详细解释 web.xml 文件中的配置项和相关知识点。 1. 配置 Struts 的 ActionServlet 在 ...

    struts-config.xml配置详解.txt

    这个strut-config配置详解是韩顺平老师指定的 很多同学都看过韩老师的视频或者上过韩老师的课程吧

    struts.xml文件详解

    Struts.xml 文件是 Apache Struts 2 框架的核心配置文件,用于定义应用程序的行为、组织 Action、拦截器以及结果页面等。以下是该文件的主要组成部分和相关知识点的详细解释: 1. **DOCTYPE 声明**: DOCTYPE 声明...

    struts.properties配置详解

    在Struts2框架中,除了大家熟知的`struts.xml`配置文件之外,还有一个重要的配置文件——`struts.properties`。该文件主要用来存储一些Struts2的核心配置属性,通过键值对的方式设置框架的行为模式、国际化设置以及...

    truts.xml-struts.properties-详

    通过阅读`truts.xml_struts.properties_详解共6页.pdf.zip`中的内容,你将深入理解这两个配置文件的详细用法和最佳实践。这个压缩包可能包含了关于Action配置、拦截器配置、结果类型、异常处理、国际化和自定义配置...

Global site tag (gtag.js) - Google Analytics