谁能帮我把jsp页面中的java代码改成jstl
<%
Map shopcart = (Map) session.getAttribute("shopcart");
if (shopcart != null) {
Object[] goodNames = (Object[]) shopcart.keySet().toArray();
for (Object x : goodNames) {
Map goodInfo = (Map) shopcart.get(x);
String goodName = (String) goodInfo.get("goodName");
Integer mount = (Integer) goodInfo.get("mount");
//取出该物品购买的数量
out.print("<tr><td>" + goodName + "</td>");
//输出物品名
out.print("<td>" + mount + "</td></tr>");
}
} else {
out.println("您没有没有购买任何物品");
}
%>
jsp
java
jstl
------解决方案--------------------<c:choose>
<c:when test ="${shopcart !=nul;}">
<c:forEach var="map" items="${shopcart}">
<tr><td>${map.value['goodName'] }</td>
<tr><td>${map.value['mount'] }</td>
</c:forEach>
</c:when>
<c:otherwise>
您没有购买任何物品
</c:otherwise>
</c:choose>