<%
Map cart = (Map) session.getAttribute("cart");
if (cart == null || cart.size() == 0) {
out.println("<p>购物车当前为空。</P>");
} else {
Set cartItems = cart.keySet();
Object[] foodItems = cartItems.toArray();
double total = 0;
for (int i = 0; i < foodItems.length; i++) {
CartItemBean cartItem = (CartItemBean) cart
.get((String) foodItems[i]);
FoodBean food = cartItem.getfood();
int quantity = cartItem.getQuantity();
double price = food.getFoodPrice();
double subtotal = quantity * price;
total += subtotal; %>
我的添加物品到购物车的代码如上面所示,那么清空的时候又该如何实现呢?