Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

struts 2 iterator with range

Tags:

struts2

I have an array of strings. Lets say array[] containing 5 strings: "a", "b", "c", "d", "e" Now I want to display only strings at position 3 and 4 in the jsp file. How do I do that with s:iterator tag ? (just like a normal for loop starting at 3 and ending at 4)

Is there a way to loop with s:iterator with a begin and end value just like a normal loop ?

Thanks!

like image 769
Tommy Lord Avatar asked Sep 10 '26 18:09

Tommy Lord


1 Answers

Why not just use iterator tag with begin and end attributes.
Example from Struts2 tag reference:

<s:iterator value="{1,2,3,4,5}" begin="2" end="4" >
    <!-- current iteration value (2,3,4) -->
    <s:property value="top" />
</s:iterator>
like image 159
doctrey Avatar answered Sep 15 '26 12:09

doctrey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!