Question

<s:iterator value="MyList" status="idx">
     <% int index = %><s:property value = '%{#idx.index}'/><% ; %>
</s:iterator>

The above code does not work. how can the integer value of the 'idx' be stored in the variable 'index'?

Was it helpful?

Solution

Instead of using java variables creating a struts variable works fine.

<s:set name="newVariable" value="%{#idx.index}" />

whenever you need to access the newly created struts variable. You can use this

<s:property value="#newVariable" />

OTHER TIPS

you can access the list value in jsp using

<s:property value="dataname"/>

dataname is your pojo generated database columns

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top