• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2 Iterator

 
Rajkumar Kathiresan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a two map "student","address" in my action class.


I want to get the values from address map using the key of student map. ie., i need to append "S" with the key of student & need to pass that new value as a key for address Map. I tried some thing but its not working...



any one help me on this...
 
Peter Searls
Greenhorn
Posts: 9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I modified your example a little to make things a little clearer.

Here are the entries from the jsp:
The iterator returns the EntrySet for each entry in the map.
To display the Student values you can just use the getKey() and getValue() methods.
To look up the student key to get the address, append the getKey() from the entrySet with
a literal 'S'.

Here are the results:
Student Key: 1 - Student Value: AAAA
Address Value: STREET1
Student Key: 2 - Student Value: BBBB
Address Value: STREET2

I hope this helps.

Pete Searls
 
Rajkumar Kathiresan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lol It worked for me Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic