سؤال

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

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

you can access the list value in jsp using

<s:property value="dataname"/>

dataname is your pojo generated database columns

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top