java - how to populate html table with hashmap k,v? -


i have hashmap k v, , there dup keys there, like:

123 foo

123 goo

345 ggg

567 kkk

i want populate html table info, if there duplicates, how print it:

for (map.entry<string, list<string>> entry : total.entryset()) {   (string s : entry.getvalue()) {     system.out.println(entry.getkey() + " " + s);   } } 

so how can populate table, tried this:

<table id="ptable" border="1">              <tr>                     <td style="text-align: center;">id</td>                     <td style="text-align: center;">month</td>             </tr> </table> 

and then:

< c:foreach var="employeehash" items="${employeehash}" >     <td>${employeeskills.key.id}</td> </c:foreach> 

but dont know how value each key...

i want final res like:

key val

123 kkk

123 fff

345 lll

assuming employeeobjmap has key , values. following code should work.

<table>   <th>key</th>   <th>value</th>   <c:foreach items="${employeeobjmap }" var="current">     <tr>       <td><c:out value="${current.key}" /><td>       <td><c:out value="${current.value}" /><td>     </tr>   </c:foreach> </table> 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -