English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Struts 2Detailed Explanation of constant Configuration

1.<constant name="struts.i18n.encoding" value="UTF-8" />
Specifies the default character encoding set for the Web application, which is equivalent to calling the setCharacterEncoding method of HttpServletRequest.

2.<constant name="struts.i18n.reload" value="false"/>
This attribute determines whether the system reloads the resource files each time an HTTP request arrives. The default value of this attribute is false. Setting this attribute to true during the development phase is more conducive to development, but it should be set to false during the product release phase.

3.<constant name="struts.custom.i"18n.resources" value="application"/>
This property specifies Struts 2The internationalization resource files required by the application. If there are multiple internationalization resource files, the filenames of multiple resource files should be separated by English commas (,),

4.<constant name="struts.action.extension" value="action" />
This property specifies the need for Struts 2The request suffixes that this property processes, the default value of this property is action, which means all matches*Requests with the suffix .action are processed by Struts 2If the user needs to specify multiple request suffixes, the multiple suffixes should be separated by English commas (,),

5.<constant name="struts.serve.static.browserCache " value="true" />
Whether the browser caches static content, the default value is true (used in production environment), it is best to disable it in the development stage.

6.<constant name="struts.configuration.xml.reload" value="false" />
when struts 2The system automatically reloads the file after the configuration file is modified, the default value is false (used in production environment), it is best to enable it in the development stage.

7.<constant name="struts.configuration.files" value="struts-default.xml, struts-plugin.xml, struts.xml"/>
This property specifies Struts 2The framework loads the default configuration file. If you need to specify multiple configuration files to be loaded by default, the filenames of multiple configuration files should be separated by English commas (,),. The default value of this property is struts- default.xml, struts-plugin.xml, struts.xml, you should understand why Struts 2The framework loads the struts.xml file by default.

8.<constant name="struts.configuration" value="org.apache.struts2.config.DefaultConfiguration"/>
to load struts2Configuration file manager, the default is org.apache.struts2.config.DefaultConfiguration, developers can customize the configuration file manager. This class must implement the Configuration interface and can automatically load struts2Configuration file.

8<constant name="struts.continuations.package" value="">/>
The complete and continuous package name containing Actions.

10<constant name="struts.devMode" value="true"> />
Used in development mode, which can print more detailed error information.

11<constant name="struts.serve.static.browserCache" value="false">/>
This property sets whether the browser caches static content. When the application is in the development phase, we want to get the latest response from the server for each request, so this property can be set to false.

12<constant name="struts.enable.DynamicMethodInvocation" value="false">/>
This property sets Struts 2Whether dynamic method invocation is supported, the default value of this property is true. If dynamic method invocation needs to be disabled, this property can be set to false.

13<constant name="struts.enable.SlashesInActionNames" value="false">/>
This property sets Struts 2Whether to allow the use of slashes in Action names, the default value of this property is false. If developers want to allow the use of slashes in Action names, this property can be set to true.

14<constant name="struts.tag.altSyntax" value="true">/>
This property specifies whether to allow in Struts 2Expression syntax is used in the tag, because it is usually necessary to use expression syntax in the tag, so this property should be set to true, and the default value is true.

15<constant name="struts.devMode" value="false">/>
This property sets Struts 2Whether the application uses the development mode. If this property is set to true, more detailed and friendly error messages can be displayed when the application encounters an error. This property only accepts the values true and false, and the default value is false. Typically, in the development phase of the application, this property is set to true, and when entering the product release phase, this property is set to false.

16<constant name="struts.ui.theme" value="xhtml">/>
This property specifies the default view theme for the view label, the default value of this property is xhtml, which can be simple, xhtml, or ajax.

17.<constant name="struts.ui.templateDir" value="template"/>
This property specifies the location of the template files required for the view theme. The default value of this property is template, which means loading template files from the template path by default.

18.<constant name="struts.ui.templateSuffix" value="ftl"/>
This property specifies the suffix of the template file. The default value of this property is ftl. This property also allows the use of ftl, vm, or jsp, which correspond to FreeMarker, Velocity, and JSP templates, respectively.

19.<constant name="struts.velocity.configfile" value="velocity.properties"/>
This property specifies the location of the velocity.properties file required by the Velocity framework. The default value of this property is velocity.properties.

20.<constant name="struts.velocity.contexts" value=""/>
This property specifies the location of the Context of the Velocity framework. If the framework has multiple Contexts, they are separated by English commas (,).

21.<constant name="struts.velocity.toolboxlocation" value=""/>
This property specifies the location of the toolbox of the Velocity framework.

22.<constant name="struts.url.http.port" value=""80"/>
This property specifies the listening port of the Web application. This property is usually not very useful, as it is only when Struts 2This property provides the default port of the Web application only when generating URLs is required (e.g., Url tag).

23.<constant name="struts.url.https.port" value=""443"/>
This property is similar in function to the struts.url.http.port property, the difference being that this property specifies the encrypted service port of the Web application.

24.<constant name="struts.url.includeParams" value="none|get|all"/>
This property specifies Struts 2Whether to include request parameters when generating URLs. This property accepts three values: none, get, and all, which correspond to not including, including only GET type request parameters, and including all request parameters.

25.<constant name="struts.dispatcher.parametersWorkaround" value="false"/>
For some Java EE servers, the getParameterMap() method of HttpServlet Request is not supported, at this time, you can set the value of this property to true to solve this problem. The default value of this property is false. For WebLogic, Orion, and OC4J server, which should usually be set to true for this property.

26.<constant name="struts.freemarker.manager.classname" value=""/>
This property specifies Struts 2.The default value of this property is org.apache.struts2.views.freemarker.FreemarkerManager, which is the FreeMarker manager used by Struts 2Built-in FreeMarker manager.

27.<constant name="struts.freemarker.wrapper.altMap" value="true"/>
This property only supports the two property values of true and false, and the default value is true. Usually, there is no need to modify the value of this property.

28.<cosntant name="struts.freemarker.templatesCache" value="false" />
Set whether to cache freemarker template settings, which is equivalent to copying template to WEB_APP/templates.

29.<constant name="struts.xslt.nocache" value="false"/>
This property specifies whether the XSLT Result uses a stylesheet cache. When the application is in the development phase, this property is usually set to true; when the application is in the product usage phase, this property is usually set to false.

30.<constant name="struts.custom.properties" value="application,org"/apache/struts2/extension/custom
"/>
Specifies Struts2The application loads a user-defined properties file, and the properties specified in the custom properties file will not override the properties specified in the struts.properties file. If multiple custom properties files need to be loaded, the filenames of the multiple custom properties files are separated by English commas (,). (That is, do not rewrite struts.properties!)
31<constant name="struts.locale" value="zh_CN">/>
Default internationalization region information.

32<constant name="struts.mapper.class" value="org.apache.struts2.dispatcher.mapper.DefaultActionMapper"/>
Specifies the request URL and action mapper, the default is org.apache.struts2.dispatcher.mapper.DefaultActionMapper

33<cosntant name="struts.mapper.alwaysSelectFullNamespace" value="false"> />
Sets whether any position before the last slash is always selected for namespace

34<constant name="struts.multipart.maxSize" value="2097152"/>
The maximum size of multipart request information (used for file upload, this property specifies Struts 2The maximum number of bytes allowed for the entire request content during file upload).

35<constant name="struts.multipart.parser" value="cos">/>
This property specifies the handling of MIME-type multipart/form-data, file upload (cos, pell, jakarta)
org.apache.struts specifically for multipart request information usage2.dispatcher.multipart.MultiPartRequest parser interface (used for file upload).

36<constant name="struts.multipart.saveDir" value="/tmpuploadfiles/>
Specifies the temporary directory for uploading files, the default is javax.servlet.context.tempdir.

37<constant name="struts.objectFactory" value="spring"> />
This property specifies Struts 2The Action in it is created by the Spring container.

38<constant name="struts.objectFactory.spring.autoWire" value="name">/>
 Specifies the assembly mode of the Spring framework, the assembly methods include: name, type, auto, and constructor (name is the default assembly mode)

39.<constant name="struts.objectFactory.spring.useClassCache" value="true">/>
This property specifies whether to cache beans when integrating spring, the value is true or false, the default is true.

40.<cosntant name="struts.objectTypeDeterminer" value="tiger"> />
Specifies type checking, including tiger and notiger

struts2Detailed Explanation of constant Configuration

This article mainly explains struts2The constant configuration in it mainly comes from the Internet.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
 "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!--Specifies the default encoding set of the Web application. This property is very useful for handling Chinese request parameters, and for obtaining Chinese request parameter values, this property value should be set to GBK or GB2312 
      Tip: When setting this parameter to GBK, it is equivalent to calling the setCharacterEncoding method of HttpServletRequest>
<constant name="struts.i18n.encoding" value="UTF-8" />
<!--Specifies Struts2The default ObjectFactory Bean, the default value of this property is spring.>
<constant name="struts.objectFactory" value="spring"> />
<!--Specifies the automatic wiring mode of the Spring framework, the default value of this property is name, which means that it is automatically assembled according to the name attribute of the Bean by default.>
<constant name="struts.objectFactory.spring.autoWire" value="name"> />
<!--This property specifies whether to cache Bean instances when integrating the Spring framework, this property only allows the use of the two property values of true and false, and its default value is true. It is usually not recommended to modify this property value.>
<constant name="struts.objectFactory.spring.useClassCache" value="true"> />
<!--This property specifies the handling of multipart/form-The MIME type of the data (file upload) request framework, which supports properties such as cos, pell, and jakarta, respectively corresponding to file upload frameworks using cos,
   pell upload and common-fileupload file upload framework, the default value of this property is jakarta.
   Note: If you need to use the file upload methods of cos or pell, you should copy the corresponding JAR file to the Web application. For example, if you use the cos upload method, you need to download the JAR file of the cos framework yourself,
   and place the file in the WEB-INF/in the lib path.
<constant name="struts.multipart.parser" value="jakarta"> />
<!--This property specifies the temporary save path for uploaded files, and the default value of this property is javax.servlet.context.tempdir.
<constant name="struts.multipart.saveDir" value=""> />
<!--This property specifies Struts 2The maximum number of bytes allowed for the entire request content during file upload.
<constant name="struts.multipart.maxSize" value="1000000000000" />
<!--This property specifies the need for Struts 2The request suffixes that this property processes, the default value of this property is action, which means all matches*Requests with the suffix .action are processed by Struts 2Processing.
If the user needs to specify multiple request suffixes, multiple suffixes should be separated by English commas (,).
<constant name="struts.action.extension" value="do"> />
<!--This property sets whether static content service is provided through JAR files, and this property only supports the values true and false. The default value of this property is true.
<constant name="struts.serve.static" value="true"> />
<!--This property sets whether the browser caches static content. When the application is in the development phase, we hope to get the latest response from the server with each request, so this property can be set to false.
<constant name="struts.serve.static.browserCache" value="true"> />
<!--This property sets Struts 2Whether the application uses the development mode. If this property is set to true, more detailed and friendly error messages can be displayed when the application encounters errors.
This property only accepts the values true and false, and its default value is false. Usually, in the development phase of the application, this property is set to true, and when entering the product release phase, this property is set to false.
<constant name="struts.devMode" value="false"> />
<!--This property sets whether the system reloads the resource files each time an HTTP request arrives (allows internationalization file reloading). The default value of this property is false.
Setting this property to true in the development stage is more conducive to development, but it should be set to false in the product release stage.
Tip: Set this property to true in the development stage to reload internationalization resource files with each request, allowing developers to see real-time development effects;
In the product release stage, this property should be set to false to provide response performance, as reloading resource files for each request will greatly reduce the performance of the application. >
<constant name="struts.i18n.reload" value="false" />
<!--This property specifies the default view theme for view tags, with the default value being xhtml. >
<constant name="struts.ui.theme" value="simple" />
<!--This property specifies the suffix of the template file. The default value of this property is ftl. This property also allows the use of ftl, vm, or jsp, which correspond to FreeMarker, Velocity, and JSP templates, respectively. >
<constant name="struts.ui.templateSuffix" value="ftl"> />
<!--This property sets whether the system automatically reloads the struts.xml file when the file changes. The default value of this property is false. >
<constant name="struts.configuration.xml.reload" value="false"> />
<!--This property specifies Struts 2The internationalization resource files required by the application. If there are multiple internationalization resource files, the filenames of multiple resource files are separated by English commas (,),. >
<constant name="struts.custom.i18n.resources" value="nationz" />
<!--For some Java EE servers, the HttpServlet Request call getParameterMap() method is not supported. In this case, you can set the property value to true to solve this problem.
 The default value of this property is false.
 For WebLogic, Orion, and OC4J server, usually the property should be set to true. >
<constant name="struts.dispatcher.parametersWorkaround" value="false"> />
<!--Specify whether to cache FreeMarker templates. The default value is false.>
<constant name="struts.freemarker.templatesCache" value="true"> />
<!--This property only supports the two attribute values of true and false, with the default value being true. It is usually unnecessary to modify this property value. >
<constant name="struts.freemarker.wrapper.altMap" value="true"} />
<!--This property specifies whether the XSLT Result uses a style sheet cache. When the application is in the development phase, this property is usually set to true; when the application is in the product usage phase,
This property is usually set to false. >
<constant name="struts.xslt.nocache" value="false" />
<!--This property specifies Struts 2The framework loads the default configuration file. If multiple configuration files need to be loaded by default, the filenames of multiple configuration files are separated by English commas (,),
The default value of this property is struts-default.xml, truts-plugin.xml, struts.xml, see the value of this property, so it should be clear why Struts 2The framework loads the struts.xml file by default. >
<constant name="struts.configuration.files" value="struts-default.xml, struts-plugin.xml" />
<!--Set whether the mapper always selects the full namespace. The default value of this property is false.>
<constant name="struts.mapper.alwaysSelectFullNamespace" value="false" />
<!--Set the root path for locating view resources of the Convention plugin. The default value is/WEB-INF/content>
<constant name="struts.convention.result.path" value="/WEB-INF/content/" />
<!--The Convention plugin uses the package specified by this constant as the root package>
<constant name="struts.convention.action.package" value="default" />
<!--Whether to search for Action from the package>
<constant name="struts.convention.action.disableScanning" value="false"/>
<!-- The official documentation only states that it needs to be set under jboss, the situation is unclear -->
<constant name="struts.convention.exclude.parentClassLoader" value="true" /> 
<constant name="struts.convention.action.fileProtocols" value="jar, zip" />
<!--Include which jars contain the action. Comma-separated string.>
<constant name="struts.convention.action.includeJars" value=".*?/_wl_cls_gen.*?jar(!/)?" />
<!--Determine the path of the search package. Search all packages ending with action.>
<constant name="struts.convention.package.locators" value="action" />
</struts>

Struts2 - Summary of commonly used constants

see comments

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
  "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
  "http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
  <!-- Set it to development mode, set to false when releasing -->
  <constant name="struts.devMode" value="true" />
  <!-- Set whether to hot reload when the class is modified, set to false when releasing -->
  <constant name="struts.convention.classes.reload" value="true"/>
  <!-- Automatic dynamic method invocation, after using this setting, you can call it like this: action!method -->
  <constant name="struts.enable.DynamicMethodInvocation" value="true" />
  <!-- specify the directory address where the jsp file is located -->
  <constant name="struts.convention.result.path" value="/WEB-INF/content/" />
  <!-- use struts-default default converter, use: rest if it is rest-default, rest needs the rest jar plugin -->
  <constant name="struts.convention.default.parent.package" value="struts-default"/>
  <!-- used to configure package name suffix. The default is action, actions, struts-->
  <constant name="struts.convention.package.locators" value="actions" />
  <!-- used to configure class name suffix, the default is Action, set after, Struts2will only find classes with this suffix name for mapping -->
  <constant name="struts.convention.action.suffix" value="Action"/>
  <!-- set even if there is no @Action annotation, still create Action mapping. The default value is false. Because Convention-Plugin is a style of convention over configuration,
    can access the methods in the corresponding Action without annotations based on predefined definitions -->
  <constant name="struts.convention.action.mapAllMatches" value="true"/>
  <!-- custom jsp file naming separator -->
  <constant name="struts.convention.action.name.separator" value="-" />
  <!-- internationalization resource file name -->
  <constant name="struts.custom.i18n.resources" value="i18n" />
  <!-- whether to automatically load internationalization resource files -->
  <constant name="struts.i18n.reload" value="true" />
  <!-- whether the browser caches static content -->
  <constant name="struts.serve.static.browserCache" value="false" />
   <!-- upload file size limit setting -->
  <constant name="struts.multipart.maxSize" value="-1" />
  <!-- theme, set the value to simple, which means not using UI templates. This will not generate additional html tags -->
  <constant name="struts.ui.theme" value="simple" />
  <!-- encoding format -->
  <constant name="struts.i18n.encoding" value="UTF-8" />
</struts>

basic Constants

struts.devMode optional values true, false (default false), in the development mode, struts2The dynamic reloading of configuration and resource files will take effect by default. At the same time, the development mode will also provide more comprehensive logging support.
struts.i18n.reload optional values: true, false (default value depends on struts.devMode), whether to automatically reload local resource files
struts.i18n.encoding is mainly used to set the request encoding (default value (UTF-8Encoding for parsing Head and Include tags, and for parsing resource and configuration files.
struts.configuration.xml.reload optional values: true, false (default value depends on struts.devMode), whether to automatically reload the XML configuration file
struts.action.extension sets the suffix of the struts Action request, supports multiple, separated by commas
struts.action.excludePattern sets the URLs excluded by struts (matched by regular expressions) (supports multiple, separated by commas)
struts.tag.altSyntax optional values: true, false (default true), whether to support ognl expressions
struts.url.http.port sets the HTTP port corresponding to the generated URL
struts.url.https.port sets the HTTPS port corresponding to the generated URL
struts.url.includeParams optional values: none, get, all (default get), sets whether the URL includes parameters and whether only GET method parameters are included
struts.locale sets struts2The default locale determines which resource file to use.
struts.ui.templateDir specifies the location of the template files required by the view theme, the default value of this attribute is template, which means loading template files from the template path by default
struts.ui.theme specifies the default view theme for the view tags, the default value of this attribute is xhtml.
struts.ui.templateSuffix specifies the suffix of the template file, the default value of this attribute is ftl. This attribute also allows the use of ftl, vm, or jsp, which correspond to FreeMarker, Velocity, and JSP templates respectively
struts.multipart.saveDir sets the default directory for saving temporary uploaded files
struts.multipart.maxSize sets the maximum limit for the temporary file upload
struts.objectFactory.spring.autoWire Optional values (name, type, auto, constructor,name) (default name), set the spring automatic wiring method, effective only after the spring plugin is introduced
struts.objectFactory.spring.autoWire.alwaysRespect (default false) Set whether objects are always created with the automatic wiring strategy
struts.objectFactory.spring.useClassCache (default false) Whether the object factory uses class cache, invalid in development mode
struts.xslt.nocache (default false) Set whether XsltResult should not use cache
struts.custom.properties Set the list of user-defined property file names (separated by commas)
struts.custom.i18n.resources Set the list of user-defined resource file paths (separated by commas)
struts.serve.static (default false) Set whether to support static resource requests (require URL to be under struts or static)
struts.serve.static.browserCache (default false) Whether to set cache in the static resource response. Only effective when static resources are supported
struts.el.throwExceptionOnFailure (default false) Whether to throw RuntimeException when parsing EL expressions or unable to find properties
struts.ognl.logMissingProperties (default false) Whether to log the missing properties
struts.ognl.enableExpressionCache Whether to cache the ognl parsed expressions
struts.enable.DynamicMethodInvocation (default false) Whether to support dynamic method invocation, specifying the method through !method in the URL
struts.enable.SlashesInActionNames Whether to support slashes in the Action segment of the URL
struts.mapper.alwaysSelectFullNamespace (default false) Whether to always use the URL segment before the last slash as the namespace
core object Constants

struts.actionProxyFactory sets the entity factory for ActionProxy, which also generates the default ActionInvoctation
struts.xworkConverter sets the XWorkConverter object, which is used to obtain various types of converters.
struts.unknownHandlerManager sets the implementation class of UnknownHandlerManager, used to handle exceptions such as not finding methods.
struts.multipart.handler sets the handler for mutipartRequest (default is jakarta) corresponding class, org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest
struts.mapper.class optional values (struts, composite, restful, restful2). Sets URL parsing and mapping to ACTION implementation, (default struts).
struts.mapper.prefixMapping maps the URL prefix to the corresponding Mapper, the format is urlPrefix1:mapperName2,urlPrefix2:mapperName2. must add mapperClass as org.apache.struts2.dispatcher.mapper.PrefixBasedActionMapper, and specify struts.mapper.class as the mapper.
struts.mapper.composite sets whether to support composite (multiple) actionMapper, mapperName is separated by commas. struts.mapper.class must be set to composite for it to take effect
struts.mapper.idParameterName is used for Restful2ActionMapper acts as the parameterName corresponding to the id in the URL.
struts.ognl.allowStaticMethodAccess (default false) sets whether the ognl expression supports static methods.
struts.configuration sets struts2The Settings class.2.1.2No longer used after)
struts.urlRenderer setting struts2The URL render (used for generating URLs), (default struts), class name org.apache.struts2.components.ServletUrlRenderer
struts.objectFactory setting struts2The object factory, default (struts), class name org.apache.struts2.impl.StrutsObjectFactory, when introducing struts2-After the spring plugin is introduced, it is modified to org.apache.struts2.spring.StrutsSpringObjectFactory
struts.xworkTextProvider setting struts2The implementation of the resource file content provider. The default is com.opensymphony.xwork2.TextProviderSupport
struts.actionValidatorManager setting ActionValidatorManager's implementation class.
struts.valueStackFactory setting struts2The implementation of the ValueStack factory.
The implementation of struts.reflectionProvider setting ReflectionProvider.
The implementation of struts.reflectionContextFactory setting ReflectionContextFactory.
The implementation class of struts.patternMatcher setting PatternMatcher.
The implementation class of struts.staticContentLoader setting StaticContentLoader.

You May Also Like