JR Galia
JR Galia

Reputation: 17269

Display LinkedHashMap in Struts 2

I have a map in jsp

<s:set name="answer" value="#{0:'No', 1:'Yes', 2:'Maybe' }"/>

How to access the answer map using the key?

<s:property value="?"/>

Upvotes: 0

Views: 340

Answers (2)

Dave Newton
Dave Newton

Reputation: 160201

Edit: Sorry, mis-read on mobile device.

#theMap[theKey]

Variables created with <s:set> are named variables and must be accessed using the leading #.

Upvotes: 1

74H1R
74H1R

Reputation: 3514

Try this

<s:set name="answer" value="#{'0':'No', '1':'Yes', '2':'Maybe' }"/>
   <s:property value="#answer['1']"/>

Upvotes: 1

Related Questions