//Map 中封装 list 测试 Map<String,List<String>> mapLsit= new HashMap<>(); List<String> listStr = new ArrayList<>(); listStr.add("beijing"); listStr.add("shanghai"); listStr.add("guang_dong"); mapLsit.put("address",listStr); model.addAttribute("mapLsit",mapLsit);
JSP获取值
<br>MapMap封装List数据 <table> <thead> <tr> <th>序号</th> <th>地址</th> </tr> </thead> <tbody> <c:forEach var="map" items="${mapLsit}" varStatus="status"> <c:forEach var="m" items="${map.value}" varStatus="status"> <tr> <td>${status.index + 1}</td> <td>${m}</td> </tr> </c:forEach> </c:forEach> </tbody> </table>
本文通过一个具体的示例展示了如何在Java中使用Map来封装List,并在JSP页面上展示这些数据。示例中详细介绍了Map和List的创建过程,以及如何将它们传递到JSP页面进行迭代显示。
3857

被折叠的 条评论
为什么被折叠?



