struts2的strut.xml 配置文件详解

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "struts-2.1.dtd" >

<struts>

    <include file=""></include>  <!--导外部的配置文件-->
    <constant name="struts.devMode" value="true"></constant> <!--定义常量的配置  参见Struts2核心包 core中的 default.properties文件中有大量的constant配置-->
<!--    <bean type="org.apache.struts2.dispatcher.multipart.MultiPartRequest" name="jakarta" class="org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest" scope="default" />-->
<!--    <constant name="struts.multipart.handler" value="jakarta" />-->
    
    
    
    
    <package name="xxxxx" extends="struts-default" namespace="/">
        
        <!--    配置拦截器栈    -->
        <interceptors>
            <interceptor name="aaa" class="自定的 拦截器(配置拦截器栈)"></interceptor>
            
            <interceptor-stack name="xxx1">
                <interceptor-ref name="aaa"></interceptor-ref> <!--自定义的先写-->
                <interceptor-ref name="defaultStack"></interceptor-ref> <!--默认的-->
            </interceptor-stack>
        </interceptors>
        
        <default-interceptor-ref name="xxx1"></default-interceptor-ref><!--    指定使用的拦截器    -->
        
        
        <!--  配置全局的结果集      -->
        <global-results>
            <result name="error" >/index.jsp</result>
        </global-results>
        

<!--   struts-default中的代码段
        
      <result-types> 常使用的结果集有 Dispatcher, redirect, redirectAction-->
<!--            <result-type name="chain" class="com.opensymphony.xwork2.ActionChainResult"/>-->
<!-- <result-type name="dispatcher" class="org.apache.struts2.dispatcher.ServletDispatcherResult" default="true"/>-->
<!-- <result-type name="freemarker" class="org.apache.struts2.views.freemarker.FreemarkerResult"/>-->
<!-- <result-type name="httpheader" class="org.apache.struts2.dispatcher.HttpHeaderResult"/>-->
<!-- <result-type name="redirect" class="org.apache.struts2.dispatcher.ServletRedirectResult"/>-->
<!-- <result-type name="redirectAction" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>-->
<!-- <result-type name="stream" class="org.apache.struts2.dispatcher.StreamResult"/>-->
<!-- <result-type name="velocity" class="org.apache.struts2.dispatcher.VelocityResult"/>-->
<!-- <result-type name="xslt" class="org.apache.struts2.views.xslt.XSLTResult"/>-->
<!-- <result-type name="plainText" class="org.apache.struts2.dispatcher.PlainTextResult" />-->
<!-- </result-types>-->
        <action name="helloWorld" class="com.cn.Hello" method="hell">
            <result name="h" type="可以写上面的结果集,默认为dispatcher">/index.jsp</result>
        </action>
    </package>
    

</struts>



//常用的结果集示例




//struts2的包的继承









坚持
原文地址:https://www.cnblogs.com/gaoSJ/p/12980502.html