Note 04 Miscellaneous Notes

Source: Internet
Author: User

Process:

1. Strutsprepareandexcutefilter:strutsprepareandexcutefilter as the front-end controller, is the entire STRUTS2 dispatch center.

2. Actionmapper:actionmapper is responsible for identifying whether the current request requires Struts2 processing.

3. Actionproxy: This object acts as the middle layer between the action and the Xwork, and it proxies the action's running process.

4. The Actioninvocation:actioninvocation object describes the entire process in which the action runs.

5. Enter the Interceptor

6. Action

7. Result: Get page processing template

8. Exit the Interceptor

9. Httpservetresponse

The difference between Struts2 interceptors and filters:

1. Interceptors only work on action requests, while filters can work on almost any request.

2. The interceptor can access the action context, the object in the value stack, and the filter cannot.

3. The interceptor can be called multiple times during the life cycle of the action, and the filter can only be called once when the container is initialized.

What is the role of the default package Struts-default in Struts2?

1). The Struts-default package is built in Struts2, which defines the numerous interceptors and Result types within the struts2, while many of the core features of STRUTS2 are implemented through these built-in interceptors, such as: Encapsulating request parameters from the request to action, File Upload and

Data validation and so on are all implemented through interceptors. The package inherits the Struts-default package to use STRUTS2 to provide us with these features.

2). Struts-default package is defined in Struts-default.xml, Struts-default.xml is also the STRUTS2 default profile. STRUTS2 automatically loads the Struts-default.xml file every time.

3). Typically each package should inherit the Struts-default package.

1. Two ways to prevent forms from repeating submissions:

1). by redirection. Page redirects to the finish page. (recommended)

2). Pass the session token (token token)

2. setting character encodings in Web. XML

3. * The use of

4. struts-2.0.dtd for checking The format of the struts2.xml

5. The token interceptor's parameter name can only be includemethods and cannot be excludemethods.

6. location of the default.properties

7. the submit page suffix plus action is based on the filter in Web. Xml.

8. Stuts2 Label Submission method is automatically set to post.

9. Struts2 tag, the password will not be displayed.

Strust2 each visit generates a new action object.

One . action generally inherits Com.opensymphony.xwork2.ActionSupport.

First type conversion, followed by input checksum. When there is an error, it is automatically deposited into the fielderror .

Use the framework to validate the error message ( with the appropriate DTD file and the examples in the war package that can help )

an El expression can be used inside . The <message> can also be used to value the key to use internationalization:

The value of type is specific.

corresponding to the internationalization of the properties file

The help document is in:xwork-core-2.2.1.jar :

the Defalut.xml.

The inside of the frame automatically removes space (Dotrim) from the contents of the page , and can be <param name= "trim" >false</param> not let it eliminate whitespace. Use frame verification to eliminate the hassle of filling in spaces.!!!!!!!!!! Trim is not configured .

Chain an action to another action, in a request. redirect of two requests.

The GetSession method of Actioncontext returns a map collection. The map collection is the underlying implementation of the session, the key-value pair. The value that is stored in the session can be taken out by the Map.get () method.

in the configuration file for struts, you can redirect to a different action. If there is a parameter, then who passes it, the parameter is consistent with the attribute name. Redirect to carry parameters. The parameters in request forwarding are from the page, the parameters added in the configuration file are not effective. Parameters are not commonly used in configuration files.

17. With parameter redirection:

Struts can automatically assign values to parameters, looking for a method, not a name.

can let action Implement Interface preparable interface, implement the prepare method inside. The method is executed before the method executes in the action and can be used for initialization.

No Status: No modifiable member variables

block filtering is the Execute method. When executing a method interceptor, first check if interception is required and then select Execute.

22.

in struts, you can create a new struts.properties file that contains the corresponding attributes in the corresponding Default.propertie, and so on. You can set the upload size of the file by using the config file in struts.properties (there is no multiplication number (*)) in the XML

Configures the properties of the constant configuration. The struts.properties is configured in the global.

24.

Many things can be configured in the @Action

configuration file load order in Strust2

27. Method Filter Interceptor, interception method. The Preresultlistener class listener, whose Beforeresult method executes after the interceptor's invoke execution.

Web. XML configuration files, the original filter is not recommended to be used.

Struts2 provides 35 interceptors and 18 defaults.

The value values are automatically found in the Struts label hidden, plus the name value. If you add value, the actual value cannot be displayed.

Note 04 Miscellaneous Notes

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.