Answers for "jstl foreach hashmap"

0

jstl foreach hashmap

// Iterate HashMap With JSTL
    

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page import="java.util.HashMap"%>
<%
    HashMap<String,String> numMap = new HashMap<String,String>();
    numMap.put("1","one");
    numMap.put("2","two");
    numMap.put("3","three");
    request.setAttribute("numMap", numMap);
%>
<html>
<body>
    <c:forEach items="${numMap}" var="entry">
        ${entry.key})${entry.value}<br/>
    </c:forEach>
</body>
</html>
Posted by: Guest on September-24-2021

Browse Popular Code Answers by Language