Reputation: 41
I am new to struts2 and facing one issue.
I have following datastructure.
class Employee extends actionsupport{
Private List<Address> address;
....getters and setters
}
class Address {
private String street_name;
Private City_name;
......and so on
... getters and setters
}
how to iterate over this list in JSP using <s:iterate>
tag. I tried many combination but some way it is not working for me.
Upvotes: 1
Views: 3459
Reputation: 23587
I believe the best way is to use Struts2 iterator tag which needs to provide collection as a data-source to iterator over.
<s:iterator value="address">
<s:property value="street_name"/>
<s:property value="City_name"/>
//so on
</s:iterator>
When Iterator will iterator over the address it will place the object (Address in your case) on the top of value stack and you can refer to these properties directly as described above
Upvotes: 1
Reputation: 1125
<s:iterator value="%{address}" var="addr">
<s:property value="%{street_name}"/>
<s:property value="#addr.street_name"/>
</s:iterator>
Upvotes: 0