Struts Source Research

Source: Internet
Author: User

The Logic:iterator label (hereinafter referred to as "the label") is a very common label in struts, which is used to loop through the values in a given container object

So commonly used tags, the source code of course need to take out the study, the following list of several research results:

1, the label internal use collection to represent the given container, all the given container objects (such as ARRAYLIST,MAP, etc.) will be converted into collection

2, the label itself to maintain the circular index

3, several common attributes of the label are as follows:

Name, property, scope, ID

4, combined with the above label, give a section of source code to explain the mechanism of its work

In this source code, you can see this sentence from the beginning:

Collection = Tagutils.getinstance (). Lookup (PageContext, Name, property, scope);

This code has been analyzed in the previous struts source analysis, and it functions as follows:

1, if the property value is null, then within scope definition (that is, request, session, application, page) to find the object named with the name variable value (The return value is an object, Then convert collection)

2, if the value of the property is not NULL, then after the 1 steps of things, She's going to call the GetProperty method in the Org.apache.commons.beanutils.PropertyUtils class, get the target object, and convert it to the collection type. So, when we encode, we can build ourselves a ArrayList and then put it in the Sess Ion or request scope, and then in the logic:iterator tag you can define this:

The key value that the Name= object binds to in session or request cannot be written (because no longer wraps this ArrayList into an object)

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.