I have a map with key-value pairs. I want to display the key on a drop-down and value to be sent to server for identifying what is selected.
I am using Struts2. I tried putting the Map
in <s:select>
tags list
, however it shows the values in the dropdown.
Use listKey
and listValue
attributes of <s:select>
tag to get properties from list of objects.
In order to swap keys and values in map put value in listKey
and key in listValue
.
<s:select list="someMap" listKey="value" listValue="key"/>