Cleans up page about Constants
Project: http://git-wip-us.apache.org/repos/asf/struts-site/repo Commit: http://git-wip-us.apache.org/repos/asf/struts-site/commit/ee1df46b Tree: http://git-wip-us.apache.org/repos/asf/struts-site/tree/ee1df46b Diff: http://git-wip-us.apache.org/repos/asf/struts-site/diff/ee1df46b Branch: refs/heads/master Commit: ee1df46b1c0a9d8a8e9ac4c19684f0b92e957b7b Parents: bd650c3 Author: Lukasz Lenart <lukasz.len...@gmail.com> Authored: Fri Jul 21 14:43:52 2017 +0200 Committer: Lukasz Lenart <lukasz.len...@gmail.com> Committed: Fri Jul 21 14:43:52 2017 +0200 ---------------------------------------------------------------------- .../core-developers/constant-configuration.md | 95 ++++++-------------- 1 file changed, 28 insertions(+), 67 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts-site/blob/ee1df46b/source/core-developers/constant-configuration.md ---------------------------------------------------------------------- diff --git a/source/core-developers/constant-configuration.md b/source/core-developers/constant-configuration.md index 3dea987..ab2a6d5 100644 --- a/source/core-developers/constant-configuration.md +++ b/source/core-developers/constant-configuration.md @@ -5,110 +5,72 @@ title: Constant Configuration # Constant Configuration +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](bean-configuration.html) implementation, among multiple implementations of a given type, should be chosen. -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](#PAGE_29601) 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: +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](struts-default-xml.html) - 2. struts-plugin.xml - 3. [struts.xml](struts-xml.html) - 4. [struts.properties](struts-properties.html) - 5. [web.xml](web-xml.html) - (\!) The +> The `struts.properties` file is provided for backward-compatibility with WebWork. -~~~~~~~ -struts.properties -~~~~~~~ - file is provided for backward\-compatiblity with WebWork\. +## Constant -#####Constant##### - -In the various XML variants, the constant element has two required attributes: - -~~~~~~~ -name -~~~~~~~ - and - -~~~~~~~ -value -~~~~~~~ -\. +In the various XML variants, the constant element has two required attributes: `name` and `value`. |Attribute|Required|Description| |---------|--------|-----------| |name|**yes**|the name of the constant| |value|**yes**|the value of the constant| -In the [struts.properties](struts-properties.html) file, each entry is treated as a constant\. - -In the [web.xml](web-xml.html) file, any FilterDispatcher initialization parameters are loaded as constants\. - -__Value substitution__ +In the [struts.properties](struts-properties.html) file, each entry is treated as a constant. -Since Apache Struts 2\.5\.6 it is possible to use value substitution when defining +In the [web.xml](web-xml.html) file, any FilterDispatcher initialization parameters are loaded as constants. -~~~~~~~ -constant -~~~~~~~ -s in +### Value substitution -~~~~~~~ -struts.xml -~~~~~~~ - file\. You can also define a default value if given System property or ENV variable is missing, see example below: +Since Apache Struts 2.5.6 it is possible to use value substitution when defining `constant`s in `struts.xml` file. +You can also define a default value if given System property or ENV variable is missing, see example below: - -~~~~~~~ +```xml <struts> <constant name="os" value="Current OS = ${os.name}"/> - <constant name="struts.devMode" value="${env.STRUTS_DEV_MODE:false}"/> </struts> -~~~~~~~ - -Note: substitution is limited to System properties and ENV variables and works only for +``` -~~~~~~~ -constant -~~~~~~~ -s (as for now)\. +Note: substitution is limited to System properties and ENV variables and works only for `constant`s (as for now). -__Sample usage__ +## Examples -**Constant Example (struts\.xml)** +**Constant Example (struts.xml)** - -~~~~~~~ +```xml <struts> <constant name="struts.devMode" value="true" /> - ... </struts> +``` -~~~~~~~ +**Constant Example (struts.properties)** -**Constant Example (struts\.properties)** - - -~~~~~~~ +``` struts.devMode = true +``` -~~~~~~~ - -**Constant Example (web\.xml)** +**Constant Example (web.xml)** - -~~~~~~~ +```xml <web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" @@ -116,7 +78,7 @@ struts.devMode = true <filter> <filter-name>struts</filter-name> - <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> + <filter-class>org.apache.struts2.dispatcher.StrutsPrepareAndExecuteFilter</filter-class> <init-param> <param-name>struts.devMode</param-name> <param-value>true</param-value> @@ -126,5 +88,4 @@ struts.devMode = true ... </web-app> - -~~~~~~~ \ No newline at end of file +``` \ No newline at end of file