<< back to Core Developers Guide Edit on GitHub

# struts-default.xml

A base configuration file named `struts-default.xml` is included in the `struts2-core.jar` file. This file is automatically included into `struts.xml` file to provide the standard configuration settings without having to copy them.

> To exclude the `struts-default.xml` or to provide your own version, see the `struts.configuration.files` setting in default.properties.

The content of `struts-default.xml` is here:

    <?xml version="1.0" encoding="UTF-8" ?>
    <!--
    /*
     * Licensed to the Apache Software Foundation (ASF) under one
     * or more contributor license agreements.  See the NOTICE file
     * distributed with this work for additional information
     * regarding copyright ownership.  The ASF licenses this file
     * to you under the Apache License, Version 2.0 (the
     * "License"); you may not use this file except in compliance
     * with the License.  You may obtain a copy of the License at
     *
     *  http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing,
     * software distributed under the License is distributed on an
     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     * KIND, either express or implied.  See the License for the
     * specific language governing permissions and limitations
     * under the License.
     */
    -->

    <!DOCTYPE struts PUBLIC
            "-//Apache Software Foundation//DTD Struts Configuration 6.0//EN"
            "https://struts.apache.org/dtds/struts-6.0.dtd">

    <struts>

        <include file="struts-excluded-classes.xml"/>
        <include file="struts-beans.xml"/>

        <package name="struts-default" abstract="true">
            <result-types>
                <result-type name="chain" class="org.apache.struts2.result.ActionChainResult"/>
                <result-type name="dispatcher" class="org.apache.struts2.result.ServletDispatcherResult" default="true"/>
                <result-type name="freemarker" class="org.apache.struts2.views.freemarker.FreemarkerResult"/>
                <result-type name="httpheader" class="org.apache.struts2.result.HttpHeaderResult"/>
                <result-type name="redirect" class="org.apache.struts2.result.ServletRedirectResult"/>
                <result-type name="redirectAction" class="org.apache.struts2.result.ServletActionRedirectResult"/>
                <result-type name="stream" class="org.apache.struts2.result.StreamResult"/>
                <result-type name="plainText" class="org.apache.struts2.result.PlainTextResult"/>
                <result-type name="postback" class="org.apache.struts2.result.PostbackResult"/>
            </result-types>

            <interceptors>
                <interceptor name="alias" class="org.apache.struts2.interceptor.AliasInterceptor"/>
                <interceptor name="chain" class="org.apache.struts2.interceptor.ChainingInterceptor"/>
                <interceptor name="coep" class="org.apache.struts2.interceptor.CoepInterceptor"/>
                <interceptor name="conversionError"
                             class="org.apache.struts2.interceptor.StrutsConversionErrorInterceptor"/>
                <interceptor name="cookie" class="org.apache.struts2.interceptor.CookieInterceptor"/>
                <interceptor name="cookieProvider" class="org.apache.struts2.interceptor.CookieProviderInterceptor"/>
                <interceptor name="clearSession" class="org.apache.struts2.interceptor.ClearSessionInterceptor"/>
                <interceptor name="coop" class="org.apache.struts2.interceptor.CoopInterceptor"/>
                <interceptor name="createSession" class="org.apache.struts2.interceptor.CreateSessionInterceptor"/>
                <interceptor name="csp" class="org.apache.struts2.interceptor.csp.CspInterceptor"/>
                <interceptor name="debugging" class="org.apache.struts2.interceptor.debugging.DebuggingInterceptor"/>
                <interceptor name="execAndWait" class="org.apache.struts2.interceptor.ExecuteAndWaitInterceptor"/>
                <interceptor name="exception" class="org.apache.struts2.interceptor.ExceptionMappingInterceptor"/>
                <interceptor name="actionFileUpload" class="org.apache.struts2.interceptor.ActionFileUploadInterceptor"/>
                <interceptor name="i18n" class="org.apache.struts2.interceptor.I18nInterceptor"/>
                <interceptor name="logger" class="org.apache.struts2.interceptor.LoggingInterceptor"/>
                <interceptor name="modelDriven" class="org.apache.struts2.interceptor.ModelDrivenInterceptor"/>
                <interceptor name="scopedModelDriven"
                             class="org.apache.struts2.interceptor.ScopedModelDrivenInterceptor"/>
                <interceptor name="params" class="org.apache.struts2.interceptor.parameter.ParametersInterceptor"/>
                <interceptor name="paramRemover" class="org.apache.struts2.interceptor.ParameterRemoverInterceptor"/>
                <interceptor name="actionMappingParams"
                             class="org.apache.struts2.interceptor.ActionMappingParametersInterceptor"/>
                <interceptor name="prepare" class="org.apache.struts2.interceptor.PrepareInterceptor"/>
                <interceptor name="staticParams" class="org.apache.struts2.interceptor.StaticParametersInterceptor"/>
                <interceptor name="scope" class="org.apache.struts2.interceptor.ScopeInterceptor"/>
                <interceptor name="servletConfig" class="org.apache.struts2.interceptor.ServletConfigInterceptor"/>
                <interceptor name="token" class="org.apache.struts2.interceptor.TokenInterceptor"/>
                <interceptor name="tokenSession" class="org.apache.struts2.interceptor.TokenSessionStoreInterceptor"/>
                <interceptor name="validation"
                             class="org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor"/>
                <interceptor name="workflow" class="org.apache.struts2.interceptor.DefaultWorkflowInterceptor"/>
                <interceptor name="store" class="org.apache.struts2.interceptor.MessageStoreInterceptor"/>
                <interceptor name="checkbox" class="org.apache.struts2.interceptor.CheckboxInterceptor"/>
                <interceptor name="datetime" class="org.apache.struts2.interceptor.DateTextFieldInterceptor"/>
                <interceptor name="roles" class="org.apache.struts2.interceptor.RolesInterceptor"/>
                <interceptor name="annotationWorkflow"
                             class="org.apache.struts2.interceptor.annotations.AnnotationWorkflowInterceptor"/>
                <interceptor name="multiselect" class="org.apache.struts2.interceptor.MultiselectInterceptor"/>
                <interceptor name="noop" class="org.apache.struts2.interceptor.NoOpInterceptor"/>
                <interceptor name="fetchMetadata" class="org.apache.struts2.interceptor.FetchMetadataInterceptor"/>
                <interceptor name="httpMethod" class="org.apache.struts2.interceptor.httpmethod.HttpMethodInterceptor" />

                <!-- Empty stack - performs no operations -->
                <interceptor-stack name="emptyStack">
                    <interceptor-ref name="noop"/>
                </interceptor-stack>

                <!-- Basic stack -->
                <interceptor-stack name="basicStack">
                    <interceptor-ref name="exception"/>
                    <interceptor-ref name="servletConfig"/>
                    <interceptor-ref name="httpMethod"/>
                    <interceptor-ref name="prepare"/>
                    <interceptor-ref name="checkbox"/>
                    <interceptor-ref name="datetime"/>
                    <interceptor-ref name="multiselect"/>
                    <interceptor-ref name="actionMappingParams"/>
                    <interceptor-ref name="params"/>
                    <interceptor-ref name="conversionError"/>
                </interceptor-stack>

                <!-- Sample validation and workflow stack -->
                <interceptor-stack name="validationWorkflowStack">
                    <interceptor-ref name="basicStack"/>
                    <interceptor-ref name="validation"/>
                    <interceptor-ref name="workflow"/>
                </interceptor-stack>

                <!-- Action based file upload stack -->
                <interceptor-stack name="actionFileUploadStack">
                    <interceptor-ref name="actionFileUpload"/>
                    <interceptor-ref name="basicStack"/>
                </interceptor-stack>

                <!-- Sample model-driven stack  -->
                <interceptor-stack name="modelDrivenStack">
                    <interceptor-ref name="modelDriven"/>
                    <interceptor-ref name="basicStack"/>
                </interceptor-stack>

                <!-- Sample action chaining stack -->
                <interceptor-stack name="chainStack">
                    <interceptor-ref name="chain"/>
                    <interceptor-ref name="basicStack"/>
                </interceptor-stack>

                <!-- Sample i18n stack -->
                <interceptor-stack name="i18nStack">
                    <interceptor-ref name="i18n"/>
                    <interceptor-ref name="basicStack"/>
                </interceptor-stack>

                <!-- An example of the paramsPrepareParams trick. This stack
                     is exactly the same as the defaultStack, except that it
                     includes one extra interceptor before the prepare interceptor:
                     the params interceptor.

                     This is useful for when you wish to apply parameters directly
                     to an object that you wish to load externally (such as a DAO
                     or database or service layer), but can't load that object
                     until at least the ID parameter has been loaded. By loading
                     the parameters twice, you can retrieve the object in the
                     prepare() method, allowing the second params interceptor to
                     apply the values on the object. -->
                <interceptor-stack name="paramsPrepareParamsStack">
                    <interceptor-ref name="exception"/>
                    <interceptor-ref name="alias"/>
                    <interceptor-ref name="i18n"/>
                    <interceptor-ref name="checkbox"/>
                    <interceptor-ref name="datetime"/>
                    <interceptor-ref name="multiselect"/>
                    <interceptor-ref name="params"/>
                    <interceptor-ref name="servletConfig"/>
                    <interceptor-ref name="httpMethod"/>
                    <interceptor-ref name="prepare"/>
                    <interceptor-ref name="chain"/>
                    <interceptor-ref name="modelDriven"/>
                    <interceptor-ref name="actionFileUpload"/>
                    <interceptor-ref name="staticParams"/>
                    <interceptor-ref name="actionMappingParams"/>
                    <interceptor-ref name="params"/>
                    <interceptor-ref name="conversionError"/>
                    <interceptor-ref name="validation">
                        <param name="excludeMethods">input,back,cancel,browse</param>
                    </interceptor-ref>
                    <interceptor-ref name="workflow">
                        <param name="excludeMethods">input,back,cancel,browse</param>
                    </interceptor-ref>
                </interceptor-stack>

                <!-- A complete stack with all the common interceptors in place.
                     Generally, this stack should be the one you use, though it
                     may do more than you need. Also, the ordering can be
                     switched around (ex: if you wish to have your servlet-related
                     objects applied before prepare() is called, you'd need to move
                     servletConfig interceptor up.

                     This stack also excludes from the normal validation and workflow
                     the method names input, back, and cancel. These typically are
                     associated with requests that should not be validated.
                     -->
                <interceptor-stack name="defaultStack">
                    <interceptor-ref name="exception"/>
                    <interceptor-ref name="alias"/>
                    <interceptor-ref name="servletConfig"/>
                    <interceptor-ref name="httpMethod"/>
                    <interceptor-ref name="i18n"/>
                    <interceptor-ref name="csp">
                        <param name="disabled">false</param>
                        <param name="enforcingMode">false</param>
                    </interceptor-ref>
                    <interceptor-ref name="prepare"/>
                    <interceptor-ref name="chain"/>
                    <interceptor-ref name="scopedModelDriven"/>
                    <interceptor-ref name="modelDriven"/>
                    <interceptor-ref name="actionFileUpload"/>
                    <interceptor-ref name="checkbox"/>
                    <interceptor-ref name="datetime"/>
                    <interceptor-ref name="multiselect"/>
                    <interceptor-ref name="staticParams"/>
                    <interceptor-ref name="actionMappingParams"/>
                    <interceptor-ref name="params"/>
                    <interceptor-ref name="conversionError"/>
                    <interceptor-ref name="coep">
                        <param name="disabled">false</param>
                        <param name="enforcingMode">false</param>
                        <param name="exemptedPaths"/>
                    </interceptor-ref>
                    <interceptor-ref name="coop">
                        <param name="disabled">false</param>
                        <param name="exemptedPaths"/>
                        <param name="mode">same-origin</param>
                    </interceptor-ref>
                    <interceptor-ref name="fetchMetadata">
                        <param name="disabled">false</param>
                    </interceptor-ref>
                    <interceptor-ref name="validation">
                        <param name="excludeMethods">input,back,cancel,browse</param>
                    </interceptor-ref>
                    <interceptor-ref name="workflow">
                        <param name="excludeMethods">input,back,cancel,browse</param>
                    </interceptor-ref>
                    <interceptor-ref name="debugging"/>
                </interceptor-stack>

                <!-- The completeStack is here for backwards compatibility for
                     applications that still refer to the defaultStack by the
                     old name -->
                <interceptor-stack name="completeStack">
                    <interceptor-ref name="defaultStack"/>
                </interceptor-stack>

                <!-- Sample execute and wait stack.
                     Note: execAndWait should always be the *last* interceptor. -->
                <interceptor-stack name="executeAndWaitStack">
                    <interceptor-ref name="execAndWait">
                        <param name="excludeMethods">input,back,cancel</param>
                    </interceptor-ref>
                    <interceptor-ref name="defaultStack"/>
                    <interceptor-ref name="execAndWait">
                        <param name="excludeMethods">input,back,cancel</param>
                    </interceptor-ref>
                </interceptor-stack>

            </interceptors>

            <default-interceptor-ref name="defaultStack"/>

            <default-class-ref class="org.apache.struts2.ActionSupport"/>

            <global-allowed-methods>execute,input,back,cancel,browse,save,delete,list,index</global-allowed-methods>

        </package>

    </struts>

This file defines all of the default bundled results and interceptors and many interceptor stacks which you can use either as-is or as a basis for your own application-specific interceptor stacks.

Notice the name of the package is “struts-default”

Follow @x