Usage of scope in STRUTS1

Source: Internet
Author: User
<action path= "/..."
Type= "...."
Scope= "Session/scope"
.../>
<forward name= "..." path= "..."/>
</action>

This scope, by default, is the session, that is, in the entire reply, Actionservlet automatically creates a session for you, will automatically set the data in the form into the session, The name of the session is the name of the form class that your action is associated with. The occasion is usually a page need to go down a page value is, you have to set the scope of the session, because you request to the next page, you need to take the page of the previous page to remove the data, you have to use the session.
But usually we all use the reques, one request is enough. The usual scenario is that after we call the model layer in this action, the meaning is to take the value out of the database and put the result on another JSP page to show it. The general practice is to set scope to request. Directly in this action Request.setattribute ("" ""), and then the JSP page through the label to take out the results to display. Because if you default to the session, the session will be stored more and more, you have to complete the model layer after each call to empty the session data, the latter in the form class rewrite the Reset method. Therefore, if the page is not directly continuous, we generally set the scope for request.

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.