What is the order in which the configuration files are loaded in struts2?

Source: Internet
Author: User

The dispatcher is initialized in the Struts2 Strutsprepareandexecutefilter interceptor.

In the Init method of the Dispatcher class, the load order of the configuration files is defined (the source code below)

public void init () {

if (ConfigurationManager = = null) {
ConfigurationManager = Createconfigurationmanager (defaultbeanselectionprovider.default_bean_name);
}

try {
Init_filemanager ();
Init_defaultproperties (); [1]
Init_traditionalxmlconfigurations (); [2]
Init_legacystrutsproperties (); [3]
Init_customconfigurationproviders (); [5]
Init_filterinitparameters (); [6]
Init_aliasstandardobjects (); [7]

Container Container = Init_preloadconfiguration ();
Container.inject (this);
Init_checkweblogicworkaround (container);

if (!dispatcherlisteners.isempty ()) {
for (Dispatcherlistener l:dispatcherlisteners) {
L.dispatcherinitialized (this);
}
}
} catch (Exception ex) {
if (log.iserrorenabled ())
Log.error ("Dispatcher initialization Failed", ex);
throw new Strutsexception (ex);
}
}

The order in which they are loaded is:

1.default.properties file
Function: Defines all constants in the STRUTS2 framework
Location: org/apache/struts2/default.properties

2.struts-default.xml
Function: Configuration of Bean,interceptor,result and so on.
Location: Core core jar package in struts.

Struts-plugin.xml
It is the configuration file for the plug-in used in the STRUTS2 framework.
Struts.xml
We make the configuration file used by Struts2.

3. Custom Struts.properties
is to customize the constants.

4.web.xml

It is important to note that the configuration in the post-load file will overwrite the configuration in the loaded file first.

What is the order in which the configuration files are loaded in struts2?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.