Reputation: 690
i have a Struts2 action, in which i declare a hashmap and populate values in it. i want to access the value in the hashmap in the jsp page. the key to the corresponding value is obtained as a variable in the jsp. i have tried the following:
<tr class="gradeA">
<td><s:property value="companyName" /></td>
<td><s:property value="fname" /> <s:property value="lname" /></td>
<td><s:property value="primaryPhone" /></td>
<td><s:property value="email1" /></td>
<td><s:property value="%{map[deliveryType]}" /></td>
<td><a href="<s:property value="#editUrl" />">Edit </a>
</tr>
map is the name of the hashmap instance which i created in the action and deliveryType is the variable which contains the key. any way i can obtain the value corresponding to the key?
Upvotes: 4
Views: 3989
Reputation: 50203
<s:property value="map['%{deliveryType}']" />
Obviously both map and deliveryType must have a Getter.
Upvotes: 4