Apache Struts 2 Documentation > Home > FAQs > Can we break up a large struts.xml file into smaller pieces |

Apache Struts 2 Documentation
Can we break up a large struts.xml file into smaller pieces
Edit Page Browse Space Add Page Add News
Added by digi9ten, last edited by Musachy Barroso on Jan 02, 2007 (view change) show comment hide comment
Comment: remove @see references (no documentation on those classes)
View page history

Yes, there are two approaches. We can include other struts.xml file from a bootstrap, or we can package a `struts.xml` files in a JAR. Or both.

## By Include

A typical `struts.xml` files will have one or more include elements:

    <struts>
        <include file="struts-default.xml"/>
        <include file="config-browser.xml"/>
        <package name="default" extends="struts-default">
    ....
        </package>
        <include file="other.xml"/>
    </struts>

The first `include` element tells the framework to load the `struts-default.xml`, which it will find in the `struts2.jar` file. The `struts-default.xml` file defines the "standard" interceptor and result definitions.

You can put your own <include> elements in your `struts.xml` interchangeably with <package> elements. The configuration objects will be loaded in the order of appearance. The framework reads the configuration from top to bottom and adds objects as they are referenced.

## By JAR

A "module" can be added to an application by placing a `struts.xml` and related classes into a JAR on the classpath. FreeMarker and Velocity templates can also be provided by JAR, making it possible to distribution a module in a single, self-contained JAR that is automatically configured on startup.