How can I loop through a HashMap
in JSP?
<%
HashMap countries = MainUtils.getCountries(l);
%>
Below code works for me
first I defined the partnerTypesMap
like below in the server side,
Map partnerTypes = new HashMap<>();
after adding values to it I added the object to model
,
model.addAttribute("partnerTypesMap", partnerTypes);
When rendering the page I use below foreach
to print them one by one.
${partnerTypesMap['key']}