Search code examples
javajspstruts2iteratorognl

Specify range for struts iterator when iterating over map


Using struts iterator, we can iterate over a collection, list or map.

While iterating over a list, we can specify range using begin and end values as in :

<s:iterator value="list" begin="0" end="3">
...
</s:iterator>

I wanted to know if there is a similar way of specifying range when iterating over map. I tried:

<s:iterator value="map" begin ="0" end="3">
...
</s:iterator>

But this doesn't seems to work.

I want to know if there is way to do this, and the method of course.


Solution

  • Try

    <s:iterator value="map" status="stat">
     <s:if test="#stat.count <= 3">
       ...
     </s:if>
    </s:iterator>