1、简单Map
User user = new User(); user.setName("zmy"); user.setAge(11); user.setBirthday(new Date()); request.setAttribute("user", user); Map map = new HashMap(); map.put("sname","light"); map.put("gender","male"); map.put("user",user); request.setAttribute("map",map);
${map.sname}、${map.gender}、${map.user.name}
2、c:forEach方式
Map<Integer, Object> map = new HashMap<Integer, Object>(); map.put(1, "张三"); map.put(2, "李四"); model.addAttribute("map", map);
<c:forEach items="${map}" var="content"> <span>${content.key}</span> <span>${content.value}</span> </c:forEach>