|
![]() | 作者: xuehaiwuya [xuehaiwuya]
![]() |
登录 |
小弟初学JAVA。做了一个购物车的例子,但是遇到一个Iterator,实在不明白它的使用方法。而且写的其中有一个页面始终报错。现在此页面的代码粘贴如下: 文件名称showcart.jsp 报错的地方我已注释出来了。还请各位大虾们帮帮小弟。让小弟弄明白这是怎么回事。谢了。 <%@ page language="java" pageEncoding="GB2312"%> <%@ page import="java.util.*,cn.ac.shoponline.*"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>查看购物车</title> </head> <body bgcolor="#FFFFFF"> <%@include file="init.jsp"%> <jsp:useBean id="shopcart" scope="session" class="cn.ac.shoponline.ShoppingCart" /> <% String clear = request.getParameter("clear"); //顾客要清空购物车 if(clear!=null&&clear.equalsIgnoreCase("true")){ shopcart.clear(); %> <table align="center"> <tr> <td>您的购物车已被清空,<a href="list.jsp">返回产品列表</a></td> </tr> </table> <% } if(shopcart.getltemAmount()>0){ %> <table align="center" border="1"> <thead align="center"><h2>您在购物车中加入了如下商品<h2></thead> <tr> <td>商品名称</td> <td>产地</td> <td>生产公司</td> <td>市场价</td> <td>优惠价</td> <td>数量</td> <td>小计</td> </tr> <% Collection coll = shopcart.getltems(); //在Eclipse环境下就是此处报错。红色叉号标记。提示为Iterator cannot be vesolved to a type lterator ite = coll.iterator(); while(ite.hasNext()){ Shoppingltem si = (Shoppingltem)ite.next(); Product p = si.getltem(); %> <tr> <td><%=p.getPname()%></td> <td><%=p.getPmadew()%></td> <td><%=p.getPcomp()%></td> <td><%=p.getDescription()%></td> <td><%=p.getRealprice()%></td> <td><%=si.getAmount()%></td> <td><%=p.getRealprice()*si.getAmount()%></td> <td><a href='add.jsp?amount=<%=si.getAmount()%>&add=<%=p.getPid()%>'>修改数量</a></td> </tr> <%}%> <tr align="left"> <td colspan="8">本次购物您<font color="red">本来</font>需要花费<font color="red"> <%=shopcart.getTotalReal()%></font> 在本站购买需要<font color="red"><%=shopcart.getTotalCut()%></font></td></tr> <tr align="left"> <td colspan="8">在本站购物为您<font color="red">节省了<%=(shopcart.getTotalReal()-shopcart.getTotalCut())%> </font></td></tr> <tr align="center"><td colspan="4"><a href="list.jsp">继续购买</a></td> <td colspan="4"><a href="showcart.jsp?clear="true">清空购物车</a></td></tr> </table> <% } else{ if(clear==null||(!clear.equalsIgnoreCase("true"))){ %> <table align="center"> <tr> <td>您的购物车中暂时没有任何商品,<a href="list.jsp">返回产品列表</a></td></tr></table> <% } } %> </body> </html> |
地主 发表时间: 06-07-10 18:00 |
![]() | 回复: 286 [unique] ![]() |
登录 |
//在Eclipse环境下就是此处报错。红色叉号标记。提示为Iterator cannot be vesolved to a type lterator ite = coll.iterator(); 我没这个环境,所以也没法试。出错提示你是不是输入错了一个字母,应该是resolved,而不是vesolved,如果是表示lterator不是一个类型,但你却写到了变量ite前面。 |
B1层 发表时间: 06-07-11 17:32 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号