Iterating in JSPs Using the logic:iterate Tag
Here is the options.jsp page.
- Central element is an ordinary HTML select tag
- whose body makes use of a Struts logic:iterate tag
- logic:iterate names a bean and the property
over which it wants to iterate
- in this example, the bean is
optionsForm and the property is options.
- logic:iterate also specifies an id attribute,
whose value is used to refer to the individual objects in the collection being
iterated over
- The body of logic:iterate can then refer to the
individual objects using this attribute value
- which in this case is option
- When this JSP is rendered, the values of the two string objects, "Add Team"
and "Add Player", are written to the selection box using the Struts
bean:write tag