Struts-config.xml configuration file explanation

xiaoxiao2021-03-06  37

The core of Struts is a struts-config.xml configuration file that describes all Struts components in this file. Here, the main components and the secondary components are included here. The following is Struts-config.xml containing the content of the main elements: 1. Main elements of struts-config.xml:

Note: The order of the above elements is very important, your struts-config.xml configuration file must be configured in this order, otherwise it will be wrong when your container is started. Second, Struts-Config.xml sub-elements: 1. child element contains and , its role is graphically gradienting its parent element, the content of is a 16x16 image file, and is a 32x32 image file.

As examples: /Images/smalllogo.gif /images/largelogo.gif ;/large-iconin (iCon )/iF12. child element provides information on short textuals of the parent element, as follows: short textual distribution of its Parent Element 3. child elements provide information about full-length textual, as follows: Full-Length Textual Discription of ITS Parent Element 4. child element is used to set the property value of the JavaBean set in its parent element, which is generally used in the specified genericDataSource property, extended actionMappings, and extended Global Forwards.

As follows: , three, configure the JDBC data source its configuration form as follows: < set-property property = "mincount" value = "the minimum number of connections to open" /> The description information is as follows: Attribute Description Information Key Binds DAT on ServletContext The index key of the Asource instance is not set, the default is an action.data_source_key, if there is more than one DataSource in the application, the value of the key must be set.

JDBC drive class (required) used by DriverClass, such as the JDBC URL used by com.microsoft.jdbc.sqlserver.sqlserverDriverURL (required) such as: JDBC: Microsoft: SQLServer: // xg088: 1433Maxcount At the same time, the maximum election is opened at the same time. The default value is 2 (optional) minimum number of taps that minCount, the default value is 1 (optional) username (required) username (must) Password link to the database (must) Description Description Information (Optional) ReadOnly if it is set to True, the link is read-only, default is false. (Optional) LogintimeOut creates the maximum allowable time of the link, in seconds. (Optional) AutoCommit If you are TRUE, you will force rollback every time execute. Default is true. (Optional) Example: < / data-source> 4, configuring FORMBEAN to define the instance of the FormBean that will be bound to the action. The syntax is as follows: example: 5. Configuration global forwarding global forwarding can define a few child elements, Struts will first find the corresponding in the element, if you can't find it, then go to the global Find in the forwarding configuration.

The syntax is as follows: There is an redirect property in addition to Name and Path properties, When Redirect is set to TRUE, use the httpservletresponse.sendredirect () method, otherwise use the RequestDispatcher.Forward () method to default to false. Note: If true, use the httpservletResponse.sendredirect () method, the value stored in the original HTTPSERVLETREQUEST will be lost. Example: 6, configuration It defines several sub-elements, which mainly define an action instance to the ActionServlet class, the syntax is as follows:

attributes and their description information are as follows: Attribute Description Information Path Input in the browser's URL Character (must) TYPE links to the full name of the ACTION (Optional) Name (optional) with this action to define the role of the Actionform Bean in in Domain (Session and Request), default as session. (Optional) INPUT returns the control when the bean is wrong. (Optional) ClassName Specifies the full name of the ActionMApping class called this Action class. Default with org.apache.struts.Action.ActionMapping, (Optional) Forward Specifies the JSP page corresponding to the corresponding request. (Optional) Include If there is no Forward, it starts the role of Forward. (Optional) Validate If true, the ActionForm's validate () method is called, otherwise it is not called, default is TRUE. (Optional) example: seven, configuring RequestProcessor Use the sub-elements in the struts-config.xml file to define the requestProcessor, whose syntax format is as follows: element properties and its description information is as follows: Property The full name Buffersize specifies the custom RequestProcessor class specifies the cache size used to download. The default is 4096 bytes. ContentType Define Response Text Type, Default is TEXT / HTMLDebug Defines the Current System's Error Level, Default is 0Locale if it is true, then store the local object in the user's session, default to TrueMaxFileSize Specify the maximum size of the Download file. The default is 250mmultipartClass specified to replace the entire name of the class of the org.apache.struts.upload.DiskMultipartRequesthandler class. Nocache If it is true, close the cache function of each response is turned off.

The default is FalseTempdir Specifies the temporary directory used to upload files. The default value is determined by the container: 1 2 8, configuring Message Resources to define message resources with element in the struts-config.xml file. Its syntax is as follows: element properties and its description information is as follows: Property Description Parameter gives a full-name classname defines the class name of the message resource full name, full name org.apache.struts.config.MessageResourcesConfigFactory default is defined MessageResourcesFactory class, the default is org.apache.struts.util.property.MessageResourcesFacotryKey custom binding in this resource package ServletContext attributes primary key The default is an action.Messages_key.null If you are True, you can't find the message key, return null, default is true. Example: 1 2 Note: setting key for the following purposes: Here you want to go to the StoreFrontimageResources.properties resource file The main key value is the value corresponding to "navbar.home.image".

转载请注明原文地址:https://www.9cbs.com/read-70869.html

New Post(0)