MyServlet.java
LinkedHashMap<String, LinkedHashMap<String, MyObj>> lhm =
new LinkedHashMap<String, LinkedHashMap<String, Bank>>();
LinkedHashMap<String, MyObj> lhmObj = new LinkedHashMap<String, Bank>();
lhmObj.put(arg1, arg2);
lhm.put(arg3, lhmObj);
request.setAttribute("Map", lhm);
getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
的index.jsp
<c:forEach items="${Map}" var="myMap">
<c:out value="${myMap.key}"></c:out>
<c:out value="${myMap.value}"></c:out>
</c:forEach>
我写了这段代码并成功运作,但这表明:
ADD {213412=my.package.directory.MyObj@2e6d441d,
213413=my.package.directory.MyObj@792e3bb}
我想显示MyObj中的数据。怎么做?
答案 0 :(得分:1)
此处<c:out value="${myMap.value}"></c:out>
您的${myMap.value}
返回另一个map i.e (LinkedHashMap<String, MyObj>)
因此,您需要使用${myMap.value}