I have searched around and cannot find an answer.
Say I have a list in session of 5 items in session. How do I tell if I am at a certain iteration in the loop of s:iterator? For example say list is [a,b,c,e,f]
and I want to iterate through list and print a,b,c, then inject/print d, then print e f s开发者_开发技巧o on the page it looks like the list is a b c d e f
.
I have been trying this:
<s:iterator value="example" status="stat">
<s:if test="#stat.count == '3'">
inject d...
</s:if>
<s:else>
s:property tag to print values
</s:else>
</s:iterator>
The status attribute you are looking for is "index", not "count". Also, I didn't know if it was a typo in the code or just in your post, but your status="stat" attribute has the equals sign inside the quotes. Try this instead:
<s:iterator value="example" status="stat">
<s:if test="#stat.index == '3'">
inject d...
</s:if>
<s:else>
s:property tag to print values
</s:else>
精彩评论