What is the role of resets in Struts (transfer)

xiaoxiao2021-03-06  43

Created: Wang Yi

Creation time: Sunday, June 15, 2003

first step:

Objects Visual range: Request, Session, Application, Page.

Request: Valid in a request cycle. That is to start from a button on the page to the server to return response page (including the response page).

Session: It is valid throughout the entire process of establishing a connection to the server.

Application: Valid within the entire web application.

Page: It is only valid in one JSP page.

Step 2:

ActionForm is unique in your validity (visual range).

third step:

The reset method is called before assigning values ​​for ActionForm. The role is to restore the value in the ActionForm to the initial state. In applications we can assign a initial value in the RESET to make an object on a display value.

the fourth step:

The visual range is combined with the initialization before the assignment.

Due to the second step of the characteristics, if the visual range is request, the RESET method is not important because you will generate a new ActionForm instance each time you call, so the ActionForm you operate will not share with others. It will not be affected by others; if the visual range is session, because this ActionForm is unique in the session range, you need to use this Actionform within the session range is the same an actionform, if you don't In the RESET, the first call of the variable is called Actionform is the value of it will be valid for this call, which is nothing. However, if you happen to be called again, you just need to assign a value for a part of the Actionform, then the rest of the variable will keep the last value, so that you get a "new and old mixture", I think this is not what you expect. If the visual range is Application, it is even more difficult to understand, but it will also affect you by yourself, not only you will affect yourself. Other users who use applications will affect you.

the fifth step:

Knowing the role of the reset method and the actions of ActionForm provide our flexible processing Actionform after the only feature within Scope of SCOPE. For example, you need to cross multiple pages to collect data information, then you can set Scope to Session, and do not implement the reset method - this will not be emptied to the previously collected data in each page PUT data. Finally, when you collect the data, call the ActionForm in the action, such as: ResetField.

I can't think of the specific thing, but I have to experience these characteristics when I apply, so that the power of the architecture is maximized.

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

New Post(0)