I have a Map
with key-value pairs. I want to display the key on a dropdown, and value to be sent to the server for identifying what is selected.
I am using Struts 2. I tried putting the Map
in <s:select>
tag's list
attribute, 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"/>