Method-Set the Get and set methods directly on the action, and then use the iterator iteration output in the JSP page, but be sure to pay attention to the format. This is the format that I've been doing all afternoon.
<s:iterator value= "list" id= "id" > <tr><td><s:property value= "#id. Number"/></td>/ Use tags <td>${id.name}</td></tr>//use El expressions </s:iterator>
Or do not declare ID, direct <s:property value= "number"/>
Method 2: The list is stored in request, and the display method is the same as the JSP page. But personally it is superfluous. Since struts provides the parameters of the interceptor, why don't we take advantage of it, the format is as follows:
<s:iterator value= "#request. List" >//Here must be added #request, indicating that the list is removed from the stack. You can also set an ID, but the following format is #id.number. Also must add #, indicating that the value from the stack <tr><td><s:property value= "number"/></td> <td><s:property value= " Name "/></td></tr> </s:iterator>
Hey, recently is a small problem can torture me a day of time, it seems that is because I usually study when not careful, very impetuous. One thing has not yet mastered, and hurriedly learn another thing, and easy to get into a dead alley. Often learning a new thing will be because of the previous knowledge will not, but also back to the previous legacy of the focus. This is a waste of time. Later I want to make good arrangements for my study plan, reading also want to calm down, not anxious to
This iterator article is not bad: http://hi.baidu.com/songjiafeng/blog/item/5b5a6c4bf3375e2b08f7ef71.html
Note: 1. Just read an article to say: we use struts2 some of the tags, attributes are required to accept the collection, if the collection is stored in request,session, or the value stack (not the root of the stack), you can use the # variable name of the way, If you get a value that is obtained by a specific method in the action, you need to use a way such as value= "userlist", just to remove the front #.
2. The expression used internally within the STRUTS2 label is%{} as the OGNL expression, which can be used in a JSP page with the form ${} as an El expression.