wib
wib

Reputation: 425

Fetch a map of lists in Struts 2

I am creating a map

Map<String, List<String>> hm

I fetch the data from the db and set the values in the map. Now I want to fetch these values in the JSP. I am able to iterate through the map. However I don't want to iterate through the list. Instead I want to access the elements of the list by index i.e. '0','1', etc. How can this be achieved?

<s:iterator value="mapCred">                        
                        <tr>
                            <td>
<input type="radio" id="<s:property value='key' />" />
<inpyt type="text" value="mapCred['%{key}'].get(0)" />
</s:iterator>

or

    <inpyt type="text" value="mapCred['%{key}'][0]" />

Any suggestions?

Upvotes: 0

Views: 816

Answers (1)

Roman C
Roman C

Reputation: 1

Try the following

<s:textfield name="mapCred['%{key}']" value="%{value[0]}" />

Upvotes: 1

Related Questions