做购物车JSP页面时出错了
在运行的时候,说Cart不能解决这一类型,错误的句子是:Cart cart = (Cart) request.getSession().getAttribute("cart"); 下面是页面上的代码:<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%@ page import="com.shop.cart.Cart"%>
<%@ page import="com.shop.dto.product"%>
<%@ page import="java.sql.ResultSet"%>
<%@page import="com.shop.service.productservice"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<base href="<%=basePath%>">
<title>购物车</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<link rel="stylesheet" href="glCSS/cart.css" type="text/css"></link>
</head>
<body>
<center>
<页面DIV设计。。。。。。。>(省略)
<%
if (request.getSession().getAttribute("username") != null) {
//用户类(用户个人信息)
//得到购物车
Cart cart = (Cart) request.getSession().getAttribute("cart");
Collection<product> collection = cart.getAllproduct();
System.out.println("购买数量为" + collection.size());
Iterator<product> iterator = collection.iterator();
int i = 0;
product products = null;
while (iterator.hasNext()) {
i++;
products = iterator.next();
System.out.println("商品名为" + products.getProductName());
%>
<tr>
<td width="160"><%=i%></td>
<td width="160"><%=products.getProducdID()%></td>
<td width="160"><%=products.getProductName()%></td>
<td width="160"><%=products.getProductClass()%></td>
<td width="160"><%=products.getProductPrice()%></td>
</tr>
<%
}
%>
<%
} else {
System.out.println("XXXXXXXX");
System.out.println("XXXXXXXX");
}
%>
<%
if (request.getSession().getAttribute("cart") != null) {
//得到购物车
Cart cartb = (Cart) request.getSession().getAttribute("cart");
%>
<br>
<tr>
<td width="150"></td>
<td width="150"></td>
<td width="90">
合计总金额:
</td>
<td>
¥
</td>
<td width="150"><%=cartb.getTotalSum()%></td>
</tr>
<%
}
%>
<br>
<tr>
<td width="150"></td>
<td width="90">
<a href="#">返回主页</a>
</td>
<td width="90">
<a href="#">继续购物</a>
</td>
<td width="90">
<a href="#">清空购物车</a>
</td>
<td width="150"></td>
</tr>
</table>
<div>
<hr width="920px" size="2px" noshade="noshade" color="#222">
<br>
<div id="ziti3" class="N5">
Copyright (C) 2004-2009, All Rights Reserved
</div>
</div>
</div>
</center>
</body>
</html>