tags:

views:

541

answers:

1

I have a Set with list of objects, i want to iterate this set in s:iterator tag in struts 2 and access one of the property of Object. How can i acheive this?

Sample code: class Employee{ String name; String age; .....getters and setters

}

Set empSet = new HashSet; empSet.add( ...some objects)

In Jsp: i want to access employee name

Thanks

+1  A: 

Iterator docs: http://struts.apache.org/2.1.6/docs/iterator.html

You want to do something like this:

<s:iterator value="empSet">
  <p>Name is: <s:property value="name"/></p>
</s:iterator>

Note that you'll need a getter for empSet on your Action class.

Nate
thanks...it worked
raju