Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

Yes, there are two complementary approaches. We can include other struts.xml file -format files from a bootstrap struts.xml file, or we can place multiple package a struts.xml files on the classpathin a JAR. Or both.

Including

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>

By Include

See the <include> element documentation.

You can use

The first include element tells the framework to load the struts-default.xml, which it wil 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. They 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.

@see com.opensymphony.xwork.config.ConfigurationManager
@see com.opensymphony.xwork.config.Configuration
@see com.opensymphony.xwork.config.impl.DefaultConfiguration
@see com.opensymphony.xwork.config.ConfigurationProvider
@see com.opensymphony.xwork.config.providers.XmlConfigurationProvider

Classpathing

A "modular" application may have several struts.xml files placed in various packages on the classpath.

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 startupAt startup, the framework will search down the classpath for struts.xml files and load each one, honoring any include statements.