Common struts. xml element configuration and result set configuration
1. Introduction to common element configuration of struts. xml
(1 ). Element: indicates the entire concept of a package. It has nothing to do with the package in the Code:
Logically, And other elements for module management.
Common attributes of a package:
A> name: name of the logical Subcontract. There are multiple application names. Element to ensure the uniqueness of the name attribute, because the name can be used for other Element inherited.
B> extends: for example, Element inherits B Elements, such as B Copy all content of the element to Element. General, I do custom package, should inherit struts-default package. The package in the struts-default.xml. Then the custom package can be used All result set types and interceptors.
C> namespace: namespace. Multiple actions may have the same name in the application. How to distinguish them is namespace.
The namespace and element name determine the access path of an Action.
This attribute can be left empty: namespace = "/" by default. To write this attribute, you must start /.
Namespace = "/oa"
D> abstract: abstract, : The package cannot define other elements, but can only be used by other Inherited.
(2). element: exists in Element, used to define the Action information:
A> name: indicates the name of the access Action. Note that no/header exists. (required)
The element namespace and element name determine the access path of an Action.
Access: http: // ip: port/contextPath/config/login
Access: http: // ip: port/contextPath/abc
B> class: indicates a fully qualified name of the accessed Action class. If this attribute is not configured, the com. opensymphony. xwork2.ActionSupport class is used by default.
C> method: indicates that the request will access a specified method in the Action class. If this attribute is not configured, the default value is execute.
2. struts. xml result Set Configuration:
Use of Struts2 processing results Element configuration
Partial result: Set Configure as child element
Global result: Set As Sub-element configuration of an element: the interface provided by multiple actions in a package, such as the error message interface.
First, find the logical view name returned by the Action Method in the local result, and then jump to the Action. If not, find the logical view name in the global result:
Proximity principle:
Element attributes:
Name: "name of the logical view" returned after the Action method is executed. Default Value: success
Type: The Way To jump: defined in the struts-defautl.xml:
Common attribute values of type:
Dispatcher: forward requests to jsp (share the same request): Default Value
Redirect: redirect to jsp
Chain: forward an Action request to another Action (share the same request)
RedirectAction: redirect from Action to another Action
Stream: Response stream (File Download)
The element also contains Child element, indicating parameter information.
The element has the name attribute. The default value is location, which indicates local resources:
Default Configuration:
/Views/hello/welcome. jsp
/Views/hello/welcome. jsp