Struts1. * Core configuration file struts-config.xml details

Source: Internet
Author: User

Struts1. * Core configuration file struts-config.xml details
Struts1. * Core configuration file struts-config.xml details
First, struts-config.xml is the core configuration file of struts framework, which is embedded with the following labels:
1. <struts-config> </struts-config>
This is a master tag. All the tags in the struts configuration file must be included under this tag and only one pair of this tag is allowed;
2. <display-name> </display-name> This label is used to name the current configuration file.
3. <description> </description> can be considered as a comment.
4. <form-beans> </form-beans> describes the set of form descriptors in the current module, multiple <form-bean> </form-bean> can be set internally, and each form descriptor corresponds to a form class with at most one number;
5. <form-bean> </form-bean> is used to set the form processing class and its sub-elements <form-property>
Meanings of corresponding attributes:
ClassName: used to specify the configuration class corresponding to form-bean. Generally, org. apache. struts. config. FormBeanConfig is used by default. You can also customize the processing class, but you must inherit the FormBeanConfig class.
Name: form-bean name, unique
Type: class corresponding to form-bean
6. <form-property> is used to set the attributes of ActionForm. The names and types of these attributes correspond to the attributes of ActionForm and jsp interfaces;
Meanings of corresponding attributes:
ClassName: used to specify the configuration class corresponding to form-property. Generally, org. apache. struts. config. FormPropertyConfig is used by default. You can also customize the processing class, but you must inherit the FormPropertyConfig class.
Name: form-property name, unique
Type: Data type of the form-property attribute
Initial: Specifies the initial value of the attribute. If no initial value is set, the default value is 0 if the initial value of the corresponding data type is java. lang. Integer;
7. <global-exceptions/> set of global exception handling classes in the current module. The sub-element is <exception/>
8. <exception> Configure the exception handling class (Red is required)
ClassName: Specifies the configuration class corresponding to the exception. The default value is org. apache. struts. config. ExceptionConfig.
Handler: Specifies the exception handling class. The default value is org. apache. struts. action. ExceptionHandler.
Key: Specifies the Message key that describes the exception in the Resource Bundle type.
Path: Specifies the forwarding path when an exception occurs.
Scope: Specifies the range where the ActionMessage instance is stored. The default value is request. The other value is session.
Type: required! Specifies the name of the exception class to be processed.
Bundle: Specify resource binding
9. <global-forwards> Configure at most one global jump and sub-element <forward>
10. <forward> you can configure multiple
ClassName: Specifies the configuration class corresponding to the forward element. The default value is org. apache. struts. action. ActionForward.
ContextRelative: if true, the current context is used. The path starts with "/". The default value is false.
Name: indicates the unique identifier of the forwarding path. This name is used in the action to call the jump direction.
Path: indicates the forwarding or redirection URI. It must start. The specific configuration must correspond to contextRelative.
If redirect is set to true, the redirection operation is executed. Otherwise, the request is forwarded. The default value is false.
11. <action-mappings> defines the action set. The sub-element <action> can have at most one
12. <action> you can define multiple mappings from a specific request path to the corresponding action class. The child element <forward> specifies the corresponding jump
Attribute: Specifies the name (key) of the ActionForm Bean associated with the current Action within the range of request and session)
ClassName: configuration class corresponding to the Action element. The default value is org. apache. struts. action. ActionMapping.
Forward: indicates the URL path forwarded by the name.
Input: indicates the URL path containing the input form. If form verification fails, the request is forwarded to this URL.
Name: Specifies the name of the ActionForm Bean associated with the current Acion. This name must be defined in the form-bean element.
Path: Specifies the path to access the Action. It starts with "/" and has no extension.
Parameter: this parameter is configured for the current Action. You can obtain the parameter by calling the getParameter () method of ActionMapping in the Action execute () method.
Roles: Specifies the security role that allows the Aciton to be called. Multiple roles are separated by commas. When processing a request, RequestProcessor determines whether the user has the permission to call this Action based on this configuration item.
Scope: Specifies the scope of the ActionForm Bean. Optional values: request and session. The default value is sessi.
Type: Specifies the complete Class Name of the Action class.
Unknown: If the value is true, all invalid Action URLs sent by the user can be processed. The default value is f.
Validate: Specifies whether to call the validate () method of ActionForm Bean first. The default value is true.
Note: In the preceding attributes, forward/include/type is mutually exclusive, that is, only one of the three can exist in the same Action configuration.
13. <controller> used to configure ActionServlet
BufferSize: Specifies the buffer size for input files to be uploaded. The default value is 4096.
ClassName: Specifies the configuration class of the current controller. The default value is org. apache. struts. config. ControllerConfig.
ContentType: specifies the content type and character encoding of the corresponding result.
Locale: Specifies whether to save the Locale object to the current user's session. The default value is false.
ProcessorClass: Specifies the complete Class Name of the Java class responsible for processing requests. The default is org. apache. struts. action. RequestProcessor.
TempDir: Specifies the temporary working directory when the file is uploaded. If not set, the Servlet container will be used to assign a temporary working directory to the web application.
When nocache: true, add the specific header parameters Pragma, Cache-Control, and Expires to the corresponding results to prevent pages from being stored in the Cache of a handful of browsers. The default value is false.
14. <plug-in> Configure the Struts plug-in sub-element: <set-property>
ClassName: Specifies the Struts plug-in class. This class must implement the org. apache. struts. action. PlugIn Interface
15. <set-property> Configure plug-in attributes
Property: The property name of the plug-in.
Value: The value configured for this name.

Note: 1. All the labels described above must be set in the order of introduction; otherwise, an error will be reported.
2. I would like to introduce the <data-sources> label, but the <data-sources> label has been removed in Struts1.3, that is, it can only be configured in version 1.2, because Apache does not recommend configuring data sources in the struts-config.xml. Therefore, we recommend that you do not configure the data source in struts. If you use hibernate or spring, you can configure the data source in the hibernate configuration file or spring file. If no data source is used, configure it in tomcat.






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.