struts2ognlvaluestack

How to use <s:iterator> with an array of Object in Struts 2?


I have an ArrayList which contains a list of Object array Eg: new Object ['a','b','c'].

The list is a member variable of data object.

Now, how can I access each of 3 elements of data, while iterating them in the <s:iterator> tag:

<s:iterator value="data.list" status="cnt" var="searchList">

  <s:property value="searchList[0]"/>
  <s:property value="searchList[1]"/>
  <s:property value="searchList[2]"/>

</s:iterator>

I tried above code, but it displayed nothing.


Solution

  • <s:iterator value="data.list" status="cnt" var="searchList">
      <s:property value="#searchList[0]" />
      <s:property value="#searchList[1]" />
      <s:property value="#searchList[2]" />
    </s:iterator>