JSP中遍历map里的list,或者 遍历list里的map

xiaoxiao2021-02-28  107

页面先引入<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

如果key为int,无法直接根据key获得value,因为el标签中的数字为long型,必须把int的key改为long

遍历map里的list<br>遍历map <c:forEach items= "${uMap}" var= "map" >      获取map key    ${map.key}     遍历map 下list     <c:forEach items= "${map.value}" var= "list" ><br>  如果list是个对象,list.属性,获取属性      获取list内容 ${list.属性} ${list.属性} ${list.属性}      </c:forEach> </c:forEach>

 

遍历list里的map 先遍历List,再遍历Map。类似于 <c:forEach items="${list}" var="temp"> <c:forEach items="${temp}" var="map"> ${map.key}---->${map.value}<br> </c:forEach> </c:forEach>
转载请注明原文地址: https://www.6miu.com/read-78256.html

最新回复(0)