The mysteries of the. Action and. Do in Java Web development--struts2

Source: Internet
Author: User
Tags cos i18n xslt

Why is it possible to access the. Action when in struts? Encountered this problem when a bit dizzy, in the Internet to check some information, finally dawned! I would like to give you our experience, and hope to help you.

In fact, the problem occurs in the struts.properties configuration file , the workaround is to change the struts.action.extension to the following form Struts.action.extension=do,action

Such. Both the action and. Do are accessible.

You can also configure a lot of content in Struts.properties, which is now listed:

The following is an explanation of the struts.properties configuration file:

The Struts 2 framework has two core profiles, Struts.xml and struts.properties, where struts.xml files are primarily responsible for managing the action mappings in your app, as well as the result definitions that the action contains. In addition to this, the Struts 2 framework also contains a struts.properties file that defines a number of properties for the Struts 2 framework that developers can adapt to meet the needs of the application by changing these attributes.

The Struts.properties file is a standard properties file that contains a series of Key-value objects, each of which is a Struts 2 property, and the key corresponding to value is a Struts 2 property.

Struts.properties files are usually placed under the web-inf/classes path of the Web application. In fact, the Struts 2 framework can load the file as long as it is placed under the Classpath path of the Web App.

In fact, the contents of the Struts.properties file can be struts.xml in <constant name= "value=" "></constant> Plus

The following is a detailed list of the configuration parameters of the file, convenient for everyone to view;

Struts.configuration

This property specifies the configuration file manager that loads the Struts 2 profile. The default value for this property is Org.apache.struts2.config.DefaultConfiguration, which is the default Profile manager for Struts 2. If you need to implement your own Configuration Manager, developers can implement a class that implements a configuration interface that can load the Struts 2 configuration file on its own.

Struts.locale

Specifies the default locale for the Web app.

Struts.i18n.encoding

Specifies the default encoding set for the Web App. This property is useful for handling Chinese request parameters and should be set to GBK or GB2312 for the Chinese request parameter value.

Tip When you set this parameter to GBK, it is equivalent to calling HttpServletRequest 's Setcharacterencoding method.

Struts.objectfactory

Specifies the default objectfactory Bean for Struts 2, which is the default value of spring.

Struts.objectFactory.spring.autoWrite

Specifies the auto-assembly mode of the spring framework, which defaults to name, which is automatically assembled by default based on the bean's Name property.

Struts.objectFactory.spring.useClassCache

This property specifies whether the bean instance is cached when the spring framework is consolidated, which allows only true and false two property values, with the default value of True. Modifying this property value is not generally recommended.

Struts.objecttypedeterminer

This property specifies the type detection mechanism for Struts 2, which typically supports Tiger and notiger two attribute values.

Struts.multipart.parser: This property specifies the framework that handles the MIME type (file upload) request of Multipart/form-data, which supports attribute values such as COS, Pell, and Jakarta. That is, corresponding to the use of the Cos file upload framework, Pell upload and common-fileupload file upload framework. The default value for this property is Jakarta.

Note If you need to use the COS or Pell file Upload method, you should copy the corresponding jar file to the Web App. For example, using the Cos upload method, you need to download the jar file for the COS framework yourself and place the file under the Web-inf/lib path.

Struts.multipart.saveDir

This property specifies the temporary save path for the uploaded file, and the default value for this property is Javax.servlet.context.tempdir.

Struts.multipart.maxSize

This property specifies the maximum number of bytes allowed for the entire request content on a Struts 2 file.

Struts.custom.properties

This property specifies that the Struts 2 app loads a user-defined property file that specifies a property that does not overwrite the property specified in the Struts.properties file. If multiple custom properties files need to be loaded, the file names of multiple custom properties files are separated by commas (,).

Struts.mapper.class

Specifies that the HTTP request is mapped to the mapper for the specified action, and Struts 2 provides the default mapper: Org.apache.struts2.dispatcher.mapper.DefaultActionMapper. The default mapper completes the mapping based on the prefix of the request with the Name property of the action.

Struts.action.extension

This property specifies the request suffix that needs to be processed by Struts 2, which is the default value of the action, which means that all requests that match *.action are handled by struts 2. If the user needs to specify multiple request suffixes, the multiple suffixes are separated by commas (,).

Struts.serve.static

This property sets whether to provide a static content service through a jar file, which only supports the true and false property values, which is true for the default property value of the property.

Struts.serve.static.browserCache

This property sets whether the browser caches static content. When the app is in development, we want each request to get the latest response from the server, you can set the property to False.

Struts.enable.DynamicMethodInvocation

This property sets whether struts 2 supports dynamic method calls, and the default value for 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 sets whether struts 2 is allowed to use a slash in the action name, and the default value for this property is false. This property can be set 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 label, because the expression syntax is usually required in the label, so the property should be set to true, and the default value of this property is true.

Struts.devmode

This property sets whether the Struts 2 app uses development mode. If you set this property to True, you can display more and more friendly error hints 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 app is set to true during development, and is set to False when the product release phase is entered.

Struts.i18n.reload

This property sets whether the system reloads the resource file every time the HTTP request arrives. The default value of this property is false. Setting this property to true during development is more beneficial for development, but should be set to false during the product release phase.

Tip The development phase sets this property to true and will reload the internationalized resource file on each request, allowing developers to see real-time development effects, which should be set to false in the product release phase to provide response performance. Reloading the resource file for each request can greatly reduce the performance of the application.

Struts.ui.theme

This property specifies the view label's default view theme, which defaults to XHTML.

Struts.ui.templateDir

This property specifies the location of the template file that is required for the view theme, and the default value for this property is template, which is the templates file under the default load stencil path.

Struts.ui.templateSuffix

This property specifies the suffix of the template file, which is the default property value of FTL. This property also allows the use of FTL, VMS, or JSPs to correspond to freemarker, velocity, and JSP templates, respectively.

Struts.configuration.xml.reload

This property sets whether the system reloads the file automatically when the Struts.xml file changes. The default value for this property is false.

Struts.velocity.configfile

This property specifies the location of the Velocity.properties file required by the velocity framework. The default value for this property is velocity.properties.

Struts.velocity.contexts

This property specifies the context position of the velocity frame, and if the frame has more than one context, the multiple context is separated by a comma (,).

Struts.velocity.toolboxlocation

This property specifies the location of the toolbox for the velocity frame.

Struts.url.http.port

This property specifies the listening port on which the Web app resides. This property is typically not too large for users, but it only provides the default port for Web apps when struts 2 needs to generate a URL, such as a URL tag.

Struts.url.https.port

This property is similar to the role of the Struts.url.http.port property, except that the property specifies the cryptographic service port for the Web App.

Struts.url.includeParams

This property specifies whether the request parameters are included when Struts 2 generates the URL. This property accepts none, get, and all three property values, respectively, corresponding to a request parameter that does not contain, contains only a get type, and contains all the request parameters.

Struts.custom.i18n.resources

This attribute 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 call Getparametermap () method is not supported, and you can set the property value to True to resolve the problem. The default value for this property is false. For WebLogic, Orion, and OC4J servers, this property should normally be set to true.

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 the built-in Freemarker manager for Struts 2.

Struts.freemarker.wrapper.altMap

This property supports only true and false two property values, and the default value is true. You typically do not need to modify this property value.

Struts.xslt.nocache

This property specifies whether the XSLT result uses the stylesheet cache. This property is usually set to True when the app is in development, and is usually set to False when the app is in the product usage phase.

Struts.configuration.files

This property specifies the configuration file that the Struts 2 framework loads by default, and if you need to specify that multiple configuration files are loaded by default, separate the file names of multiple profiles with commas (,). The default value for this property is Struts-default.xml,struts-plugin.xml,struts.xml, and when you see the property value, the reader should understand why the Struts 2 framework loads the Struts.xml file by default.

The mysteries of the. Action and. Do in Java Web development--struts2

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: info-contact@alibabacloud.com 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.