aspose file tools*
The moose likes Struts and the fly likes Get  Key from Map at particular index using OGNL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Get  Key from Map at particular index using OGNL " Watch "Get  Key from Map at particular index using OGNL " New topic
Author

Get Key from Map at particular index using OGNL

kiran chirravuru
Greenhorn

Joined: Nov 25, 2009
Posts: 26
How to get Key at particular index using OGNL in struts2
Ruth Mills
Greenhorn

Joined: Apr 30, 2011
Posts: 1
This works for me, e.g. if I have a Map called "myMap" and want to get the key at index 0 from the map, then I can do something like this...

<s:hidden name="whatever" value="%{myMap.keySet().toArray()[0]}"/>

So in the OGNL, I have to call keySet() and then toArray() and can then just use an index in square brackets after that.

Hope that works for you too
 
 
subject: Get Key from Map at particular index using OGNL
 
Similar Threads
TreeMap
about hashmap implementation of arraylist
<s:submit> problem
Iterating a hashmap in jsp using struts2
.get()