Struts-config.xml configuration file explanation (1)

xiaoxiao2021-03-06  62

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, and the following is the content of struts-config.xml containing the main elements:

First, the main elements of Struts-config.xml:

"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

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 child elements:

1. child elements

It contains and , its role is to graphize its parent element, the content of is a 16x16 image file, and the content of Is a 32x32 image file. The following example:

/IMages/smalllogo.gif

/IMAGES /LARGOGO.GIF

2. Child Element

It provides information on short textuals of the parent element, as follows:

Short Textual Discription of ITS Parent Element

3. child elements

It provides information about the full-length textual (Full-Length Textual), as follows:

Full-Length Textual Discription of Its Parent Element

4. child elements

It 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 extension of Global Forwards. As follows:

Property = "Name of Bean Property"

Value = "Value of Bean Property" />

E.g:

Third, configure the JDBC data source

Its configuration form is as follows:

The properties and its description information are as follows:

Attribute description information

Key Binds the index key of the DataSource instance on servletContext, if not set, default is an action.data_source_key, if there is more than one DataSource in the application, you must set the value of the key.

JDBC driver (must) used by DriverClass, such as: com.microsoft.jdbc.sqlserver.sqlserdriver

The URL of the JDBC used in the URL (must), such as: JDBC: Microsoft: SQLServer: // XG088: 1433Maxcount At the same time, the maximum election is opened at the same time, the default is 2 (optional)

Mincount also opens minimum coupons, the default is 1 (optional)

User links to the user name (must)

Password links to the password of the database (must)

Description Information About DataSource (optional)

Readonly If 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)

for example:

Fourth, configure FORMBEAN

is used to define instances of FormBean that will be bound to the action. The syntax is as follows:

Type = "full Qualified Class Name of Formbean" />

example:

Five, configure global forwarding

Global forwarding can define several child elements, Struts will first find the corresponding in the element, and find it to the global forwarding configuration. The syntax is as follows:

In addition to the Name and Path properties, there is a redirect property. When Redirect is set to TRUE, use the httpservletresponse.sendredirect () method, otherwise, default is false.

Note: If true, use the httpservletResponse.sendredirect () method, the value stored in the original HTTPSERVLETREQUEST will be lost.

example:

Sixth, configure

It can define a few sub-elements, which mainly define an Action instance to the ActionServlet class, the syntax is as follows:

Type = "full Qualified Class Name of the Action CLASS"

Name = "The name of the form bean bound to this action">

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

New Post(0)