java - Struts2 - Result generated by append tag cannot be iterated multiple times -
here code snippet:
<s:set value="{1,2,3}" var="list1" /> <s:set value="{4,5,6}" var="list2" /> <s:append var="list3"> <s:param value="#list1" /> <s:param value="#list2" /> </s:append> <s:iterator value="#list3"> <s:property /> </s:iterator> <hr /> <s:iterator value="#list3"> <s:property /> </s:iterator> <hr />
here result:
1 2 3 4 5 6 --------------------------------------------------------------------- ---------------------------------------------------------------------
the sec <s:iterator>
tag not work @ all, happened #list3
, #list3
empty list ?
your #list3
not list reference appended iterator (instance of appenditeratorfilter
). how <s:append>
tag works. remove iteratable sources after iteration. can phone call hasnext()
method on appended iterator see if has more elements in it. , next()
method next element.
<s:iterator value="#list3"> <s:property /> <s:property value="#list3.hasnext()"/> </s:iterator>
java jsp struts2
No comments:
Post a Comment