shoppingcart.jsp
来自「《精通JSP编程 》源代码(赵强那本) 很有用的源代码」· JSP 代码 · 共 48 行
JSP
48 行
<%@ page import="jnestore.javabeans.*" %>
<%@ page import="java.util.*" %>
<h3>Shopping Cart</h3>
Here are the items you have selected:<br>
<table border=1>
<tr>
<td>SKU code</td>
<td>Product</td>
<td>Description</td>
<td>Price</td>
<td> </td>
</tr>
<%
Hashtable shoppingCart = (Hashtable)session.getAttribute("shoppingcart");
if(shoppingCart == null) {
shoppingCart = new Hashtable();
session.setAttribute("shoppingcart", shoppingCart);
}
Enumeration e = shoppingCart.elements();
float total = 0;
while(e.hasMoreElements()) {
ItemInfo item = (ItemInfo)e.nextElement();
total += item.getPrice(); %>
<tr>
<td><%=item.getSku()%></td>
<td><%=item.getName()%></td>
<td><%=item.getDescription()%></td>
<td>$<%=item.getPrice()%></td>
<td><A HREF="<%=response.encodeURL("cart.jsp?operation=removeItem&sku=" + item.getSku())%>" onClick="return confirm('Are you sure you want to remove product <%=item.getSku()%>?');">[remove]</A></td>
</tr>
<% } %>
<tr>
<td> </td>
<td> </td>
<td>
<b>Total:</b>
</td>
<td><b>$<%=total%></b></td>
<td> </td>
</tr>
</table>
<BR><BR>
<A HREF="<%=response.encodeURL("cart.jsp?operation=removeAll")%>" onClick="return confirm('Are you sure you want to remove all products?');">empty shopping cart</A>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?