Java foreach循环在打开的弹出窗口上不起作用
因为每个循环在打开的弹出窗口中都不起作用,而当我在页面上写入它时,我可以看到相同的集合Java foreach循环在打开的弹出窗口上不起作用,java,jsp,jstl,Java,Jsp,Jstl,因为每个循环在打开的弹出窗口中都不起作用,而当我在页面上写入它时,我可以看到相同的集合 <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>my cart</title> </head> <body> <% ArrayList cart=(ArrayList)session.getAttribute
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>my cart</title>
</head>
<body>
<% ArrayList cart=(ArrayList)session.getAttribute("Cart");
out.println(cart);
//this line is working
%>
<table>
<tr bgcolor="#EAEAFF">
<td><b>Product ID</b></td>
</tr>
<c:forEach items="${cart}" var="current">
<tr>
<td><c:out value="${current}"/></td>
</tr>
</c:forEach>
</table>
</body>
</html>
我的购物车
产品ID
这应该可以做到,您正在尝试获取一个可能超出默认范围(第页)的变量。
这应该可以做到,您正在尝试获取一个可能超出默认范围(第页)的变量。我发现您发布的代码存在两个问题: 1-购物车的案例是错误的。在以下代码中,您必须使用大写字母C的
购物车:
<c:forEach items="${Cart}" var="current">
如果服务器无法识别标记,它将直接将其输出到响应中。您的浏览器将无法识别
,并将忽略它(即,您在源代码中有它,但它不会显示在屏幕上)
为JSP使用以下代码,它应该可以工作:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>my cart</title>
</head>
<body>
<table>
<tr bgcolor="#EAEAFF">
<td><b>Product ID</b></td>
</tr>
<c:forEach items="${Cart}" var="current">
<tr>
<td><c:out value="${current}" /></td>
</tr>
</c:forEach>
</table>
</body>
</html>
我的购物车
产品ID
我发现您发布的代码有两个问题:
1-购物车的案例是错误的。在以下代码中,您必须使用大写字母C的购物车:
<c:forEach items="${Cart}" var="current">
如果服务器无法识别标记,它将直接将其输出到响应中。您的浏览器将无法识别
,并将忽略它(即,您在源代码中有它,但它不会显示在屏幕上)
为JSP使用以下代码,它应该可以工作:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>my cart</title>
</head>
<body>
<table>
<tr bgcolor="#EAEAFF">
<td><b>Product ID</b></td>
</tr>
<c:forEach items="${Cart}" var="current">
<tr>
<td><c:out value="${current}" /></td>
</tr>
</c:forEach>
</table>
</body>
</html>
我的购物车
产品ID
你应该发布更多的代码,主页和弹出代码会很好。使用SO标记代码。你应该发布更多代码,主页和弹出代码会很好。并对代码使用SO标记。不,他已使用keyCart
保存了它,并试图使用keyCart
访问它。要修复它,他必须使用键cart
保存它,或者使用键cart
访问它。此外,${}
只扫描属性的所有范围,而不仅仅是页面范围。不,他用键Cart
保存了它,并试图用键Cart
访问它。要修复它,他必须使用键cart
保存它,或者使用键cart
访问它。此外,${}
只扫描属性的所有作用域,而不仅仅是页面作用域。
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>my cart</title>
</head>
<body>
<table>
<tr bgcolor="#EAEAFF">
<td><b>Product ID</b></td>
</tr>
<c:forEach items="${Cart}" var="current">
<tr>
<td><c:out value="${current}" /></td>
</tr>
</c:forEach>
</table>
</body>
</html>