jstl标签中forEach标签遍历Map

 <%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%
  Map map = new HashMap();
  map.put("a", "12345");
  map.put("b", "abcde");
  out.println(map.get("a"));
  request.setAttribute("map",map);
%>
<c:forEach items="${map}" var="mymap" >
  <c:out value="${mymap.key}" />
  <c:out value="${mymap.value}" />
</c:forEach>

<c:forEach  items="${map}"  var="mymap">
    <c:if  test="${mymap.key=='a'}">
        <c:out  value="${mymap.value}"/>
    </c:if>
</c:forEach>

你可能感兴趣的:(c,HashMap,import)