Common constant command configuration methods in Struts2 _java

Source: Internet
Author: User
Tags i18n xslt

Struts.objectfactory This attribute is used to illustrate the Struts2 Object pool creation factory, STRUTS2 also has its own object pool, like spring, in which you can refer to objects in the object pool, you can use the object pool in spring, When you want to get an object pool in spring, declare struts.objectfactory to build the factory for spring's object pool ....

Struts.serve.static.browserCache This property to set whether the browser caches static content. You can set this property to False when the application is in the development phase, and we want each request to receive the latest response from the server.
Struts.enable.DynamicMethodInvocation This property to set whether Struts 2 supports dynamic method calls, and the default value of this property is true. If you need to turn off dynamic method calls, you can set this property to False.
Struts.enable.SlashesInActionNames This property to set whether Struts 2 allows a slash in the action name, and the default value of this property is false. You can set this property to True if the developer wants to allow a slash in the action name.
Struts.tag.altSyntax This property specifies whether expression syntax is allowed in the Struts 2 tag, because it is usually necessary to use expression syntax in the label, so the property should be set to TRUE and the default value of the property is true.
Struts.devmode This property to set whether the Struts 2 application uses development mode. If you set this property to True, you can display more and friendlier error prompts when an error is applied. This property accepts only true and flase two values, and the default value for this property is false. Typically, the application is set to true at development time, and this property is set to False when the product release phase is entered.
Struts.i18n.reload This property to set whether the system reloads the resource file every time the HTTP request arrives. The default value for this property is false. Setting this property to true during the development phase is more beneficial to development, but it should be set to false during the product release phase.
Tip The development phase sets this property to true, so that the internationalized resource files can be reloaded on each request, allowing developers to see the real-time development effect, which should be set to false in the product release phase to provide response performance. The need to reload resource files on each request can significantly degrade the performance of the application.
Struts.ui.theme This property specifies the default view theme for the view label, which defaults to XHTML.
Struts.ui.templateDir This property specifies the location of the template file required for the view theme, and the default value of the property is template, which is to load the template file under the template path by default.
Struts.ui.templateSuffix This property specifies the suffix of the template file, which has the default property value of FTL. This property also allows you to use FTL, VMS, or JSPs, respectively, for freemarker, Velocity, and JSP templates.
Struts.configuration.xml.reload This property to set whether the system automatically reloads the file when the Struts.xml file changes. The default value for this property is false.
Struts.velocity.configfile This property to specify the location of the file required for the velocity framework. The default value for this property is
Struts.velocity.contexts This property specifies the context position of the velocity frame, which is separated by commas (,), if the frame has multiple frames.
Struts.velocity.toolboxlocation This property to specify the position of the toolbox of the velocity frame.
Struts.url.http.port This property specifies the listening port on which the Web application resides. This property does not usually have a large user, except that it provides the default port for the Web application when Struts 2 needs to generate a URL, such as a URL tag.
Struts.url.https.port This property is similar to the Struts.url.http.port property, which specifies that the cryptographic service port of the Web application is specified by this property.
Struts.url.includeParams This property specifies whether the request parameter is included when Struts 2 generates a URL. This property accepts none, get, and all three property values, respectively, for not including, containing only get type request parameters, and containing all request parameters.
Struts.custom.i18n.resources This property specifies the Internationalized resource files required by the Struts 2 application and, if there are multiple internationalized resource files, the file names of multiple resource files are separated by commas (,).
Struts.dispatcher.parametersWorkaround for some Java EE servers, the HttpServlet request invocation Getparametermap () method is not supported. You can now set this property to true to resolve the problem. The default value for this property is false. This property should normally be set to true for WebLogic, Orion, and OC4J servers.
Struts.freemarker.manager.classname This property specifies the Freemarker manager used by struts 2. The default value for this property is Org.apache.struts2.views.freemarker.FreemarkerManager, which is a Freemarker manager built in Struts 2.
Struts.freemarker.wrapper.altMap This property supports only true and false two property values, and the default value is true. Typically, you do not need to modify this property value.
Struts.xslt.nocache This property to specify whether the XSLT result uses the style sheet cache. This property is usually set to True when the application is in the development phase, and is usually set to False when the application is in the product usage phase.
Struts.configuration.files This property specifies the configuration file that is loaded by default for the Struts 2 framework, and the file names of multiple profiles are separated by commas (,) if you need to specify that more than one configuration file be loaded by default. The default value for this property is Struts-default.xml,struts-plugin.xml,struts.xml, and the reader should see why the Struts 2 framework loads the Struts.xml file by default.

Detailed Struts2-plugin.xml Spring

  <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 ">
      <interceptor name=" autowiring "class=" Com.opensymphony.xwork2.spring.interceptor.ActionAutowiringInterceptor "/>
      <interceptor name=" Sessionautowiring "class=" Org.apache.struts2.spring.interceptor.SessionContextAutowiringInterceptor "/>

Note <constant name= "struts.objectfactory" value= "Spring"/>

Here it overwrites the frame constant struts.objectfactory and sets it to "Spring", which is actually used for abbreviations, We can write full name: Org.apache.struts2.spring.StrutsSpringObjectFactory. This abbreviated "Spring" is corresponding to the name attribute in the bean configuration. By default, all objects created by the framework are instantiated by Objectfactory, and Objectfactory provides an integrated approach to other IOC containers such as spring, Pico, and so on. A class that overrides this objectfactory must inherit the Objectfactory class or any of its subclasses, with a constructor without parameters. Here we use Org.apache.struts2.spring.StrutsSpringObjectFactory instead of the default objectfactory.

In addition, as we said above, if the action is not created using spring Objectfactory, the plug-in provides two interceptors to assemble the action automatically, and by default the framework uses the automatic assembly policy of name, which means that the framework will Spring to look for a bean with the same name as the action attribute, the optional assembly strategy is: type, auto, constructor, which we can set through constant struts.objectFactory.spring.autoWire.

In that case, we can use the bean injected in the spring IOC in the action. In fact, this is webwork early in the expansion of the package function. Oh. In exchange for strut2.0, I have to say something.

With the above configuration file, we can combine Spring2.0 and struts2.0.

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: 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.