Kamal Kannan
Kamal Kannan

Reputation: 95

how to access a struts2 property value in jsp?

<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'?

Upvotes: 1

Views: 4165

Answers (2)

Kamal Kannan
Kamal Kannan

Reputation: 95

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" />

Upvotes: 1

user2940342
user2940342

Reputation: 95

you can access the list value in jsp using

<s:property value="dataname"/>

dataname is your pojo generated database columns

Upvotes: 0

Related Questions