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

struts2Common constant Command Configuration Methods in Struts

Text2The attribute 'struts.objectFactory' is used to indicate the object pool of Struts2The object pool creation factory, Struts

It also has its own object pool, just like Spring, in the configuration file, you can refer to the objects in the object pool, you can rely on the object pool in Spring, when you want to get the object pool in Spring, declare 'struts.objectFactory' as the object pool construction factory of Spring...
The attribute 'struts.serve.static.browserCache' 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 for each request, so you can set this attribute to false. 2The attribute 'struts.enable.DynamicMethodInvocation' sets whether Struts supports dynamic method invocation, and the default value of this attribute is true. If you need to disable dynamic method invocation, you can set this attribute to false.
The attribute 'struts.enable.SlashesInActionNames' sets whether Struts supports dynamic method invocation, and the default value of this attribute is true. If you need to disable dynamic method invocation, you can set this attribute to false. 2Whether to allow the use of slashes in Action names, the default value of this attribute is 'false'. If developers wish to allow the use of slashes in Action names, this attribute can be set to 'true'.
The 'struts.tag.altSyntax' attribute specifies whether to allow the use of alternative syntax in Struts 2Expression syntax is used in the tags because it is usually necessary to use expression syntax in the tags, so this attribute should be set to 'true'. The default value of this attribute is 'true'.
The 'struts.devMode' attribute sets the Struts 2Whether the application uses the development mode. If this attribute is set to 'true', more detailed and friendly error messages will be displayed when the application encounters errors. This attribute only accepts 'true' and 'false' as values, and the default value is 'false'. Typically, this attribute is set to 'true' during the development phase and set to 'false' when entering the product release phase.
The 'struts.i' attribute is not complete, please provide the complete text for translation.18The 'n.reload' attribute sets whether the system should reload the resource files each time an HTTP request is received. 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.
Hint: Set this attribute to 'true' during the development phase, which will allow the internationalization resource files to be reloaded with each request, thus enabling developers to see the real-time development effects. During the product release phase, this attribute should be set to 'false' to provide better response performance, as reloading resource files with each request will greatly reduce the performance of the application.
The 'struts.ui.theme' attribute specifies the default view theme for the view tags. The default value of this attribute is 'xhtml'.
The 'struts.ui.templateDir' attribute specifies the location of the template files required for the view theme. The default value of this attribute is 'template', which means the template files under the 'template' path are loaded by default.
The 'struts.ui.templateSuffix' attribute 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.
The 'struts.configuration.xml.reload' attribute sets whether the system should automatically reload the 'struts.xml' file when it changes. The default value of this attribute is 'false'.
The 'struts.velocity.configfile' attribute specifies the location of the 'velocity.properties' file required by the Velocity framework. The default value of this attribute is 'velocity.properties'.
struts.velocity.contexts This attribute specifies the location of the Context of the Velocity framework. If this framework has multiple Contexts, the multiple Contexts are separated by English commas (,).
struts.velocity.toolboxlocation This attribute specifies the location of the toolbox of the Velocity framework.
struts.url.http.port This attribute specifies the listening port of the Web application where the Struts 2This attribute provides the default port of the Web application only when it is necessary to generate URLs (such as with the Url tag).
struts.url.https.port This attribute is similar in function to the 'struts.url.http.port' attribute, but the difference is that this attribute specifies the encrypted service port of the Web application.
struts.url.includeParams This attribute specifies Struts 2Whether to include request parameters when generating URLs. This attribute accepts the three property values none, get, and all, which correspond to not including, including only GET type request parameters, and including all request parameters.
struts.custom.i18n.resources This attribute specifies Struts 2The internationalization resource files required by the application. If there are multiple internationalization resource files, the filenames of the multiple resource files are separated by English commas (,).
struts.dispatcher.parametersWorkaround For some Java EE servers, the HttpServlet Request call to getParameterMap() method is not supported. In this case, you can set the value of this attribute to true to solve this problem. The default value of this attribute is false. For WebLogic, Orion, and OC4J server, and it is usually recommended to set this attribute to true.
struts.freemarker.manager.classname This attribute specifies the Struts 2The default value of this attribute is 'org.apache.struts'.2.views.freemarker.FreemarkerManager, which is the FreeMarker manager used by Struts 2Built-in FreeMarker manager.
The 'struts.freemarker.wrapper.altMap' attribute supports only the two property values true and false, and the default value is true. Usually, there is no need to modify the value of this attribute.
struts.xslt.nocache This attribute specifies whether the XSLT Result uses the style sheet cache. When the application is in the development phase, this attribute is usually set to true; when the application is in the product usage phase, this attribute is usually set to false.
struts.configuration.files This attribute specifies Struts 2frame default loads the configuration file. If you need to specify multiple configuration files to be loaded by default, the filenames of the multiple configuration files should be separated by English commas (,). The default value of this attribute is struts- default.xml, struts-plugin.xml, struts.xml, see the attribute value, readers should understand why Struts 2frame default loads struts.xml file.

detailed struts2-plugin.xml in spring

<struts>
  <bean type="com.opensymphony.xwork2.ObjectFactory" name="spring" class="org.apache.struts2.spring.StrutsSpringObjectFactory" />
  <!-- Make the Spring object factory the automatic default -->
  <constant name="struts.objectFactory" value="spring" />
  <package name="spring-default">
    <interceptors>
      <interceptor name="autowiring" class="com.opensymphony.xwork2.spring.interceptor.ActionAutowiringInterceptor"/>
      <interceptor name="sessionAutowiring" class="org.apache.struts2.spring.interceptor.SessionContextAutowiringInterceptor"/>
    </interceptors>
  </package>  
</struts

Attention <constant name="struts.objectFactory" value="spring"/>

Here, it overrides the framework constant struts.objectFactory, setting it to 'spring', which is actually using an abbreviation. We can write the full name: org.apache.struts2.spring.StrutsSpringObjectFactory. The abbreviation 'spring' corresponds to the name attribute in the bean configuration. By default, all objects created by the framework are instantiated by the ObjectFactory instance, which provides methods for integrating with other IoC containers such as Spring, Pico, etc. The class that overrides this ObjectFactory must inherit the ObjectFactory class or any of its subclasses, and must have a constructor without parameters. In this case, we use org.apache.struts2.spring.StrutsSpringObjectFactory has replaced the default ObjectFactory.

In addition, as we mentioned above, if the action is not created using the Spring ObjectFactory, the plugin provides two interceptors to automatically assemble the action. By default, the framework uses the automatic assembly strategy of name, which means the framework will look for a bean with the same name as the action attribute in Spring. Optional assembly strategies include: type, auto, constructor, and we can set it through the constant struts.objectFactory.spring.autoWire.

In this way, we can use the beans injected by Spring IOC in the Action. In fact, this is a feature that has been in the webwork extension package for a long time. Haha. Replace it with strut2We still need to mention.

With the above configuration file, we can integrate Spring2And struts2Combined together.

You May Also Like