Constants provide a simple way to customize a Struts application by defining key settings that modify framework and plugin behavior. There are two key roles for constants. First, they are used to override settings like the maximum file upload size or whether the Struts framework should be in "devMode" or not, and so on. Second, they specify which Bean implementation, among multiple implementations of a given type, should be chosen.

Constants can be declared in multiple files. By default, constants are searched for in the following order, allowing for subsequent files to override previous ones:

  1. struts-default.xml
  2. struts-plugin.xml
  3. struts.xml
  5. web.xml

(warning) The file is provided for backward-compatiblity with WebWork.


In the various XML variants, the constant element has two required attributes: name and value.






the name of the constant



the value of the constant

In the file, each entry is treated as a constant.

In the web.xml file, any FilterDispatcher initialization parameters are loaded as constants.

Value substitution

Since Apache Struts 2.5.6 it is possible to use value substitution when defining constants in struts.xml file. You can also define a default value if given System property or ENV variable is missing, see example below:

    <constant name="os" value="Current OS = ${}"/>

    <constant name="struts.devMode" value="${env.STRUTS_DEV_MODE:false}"/>

Note: substitution is limited to System properties and ENV variables and works only for constants (as for now).

Sample usage

Constant Example (struts.xml)

  <constant name="struts.devMode" value="true" />


Constant Example (
struts.devMode = true
Constant Example (web.xml)
<web-app id="WebApp_9" version="2.4" 



  • No labels


  1. Required = yes for the value attribute should be bold, not an asterisk (like there's a footnote or something).

  2. Constants only on the interpretation of why the only "struts.devMode" this one, if we want to query:
    "struts.configuration.xml.reload", "struts.i18n.encoding", "struts.ognl.allowStaticMethodAccess".
    How do we check the information and hope only in this site