| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 890 人关注过本帖
标题:为何我的购物车代码用不了?
只看楼主 加入收藏
binbinwu
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-5-26
收藏
 问题点数:0 回复次数:2 
为何我的购物车代码用不了?

我写了个购物车的JSP代码,如下:
<html>
<head>
<title>添加购物车</title>
</head>
<style type="text/css">
<body bgcolor="#FFFFFF">
<%@ page import="java.sql.*"%>
<jsp:useBean id="conn" scope="page" class="myshop.conn"/>
<%@ page import="buylist.buylist"%>
<%
String ISBN=request.getParameter("isbn");
String TITLE="";
String PRICE="";
String sql="select TITLE,PRICE from bookinfo where ISBN='"+ISBN+"'";

ResultSet rs=conn.executeQuery(sql);
if(rs.next())
{TITLE=rs.getString("TITLE");
PRICE=rs.getString("PRICE");
}

buylist mylist=new buylist();
mylist.TITLE=TITLE;
mylist.ISBN=ISBN;
mylist.number=1;
boolean listFlag=true;
Vector shop=(Vector)session.getValue("shop");
if(shop==null)
{shop=new Vector();
}
else
{
for(int i=0;i<shop.size();i++)
{buylist list=(buylist)shop.elementAt(i);

if(list.ISBN==mylist.ISBN)
{list.number++;
shop.setElementAt(list,i);
listFlag=false;
}
}
if(listFlag)shop.addElement(mylist);

session.putValue("shop".shop);
rs.close();
%>
<br><font size="4" color="#FF0033">您选购的书籍已经成功的添加到购物车中!</font></b><br>
<br>
<a href="JaavaScript:window.close()">关闭窗口</a>
<a href="list.jsp target="_blank" onclick="javaScript:window.close()">查看购物车
</a></div>
</body>
</html>

上面的mysho.conn javabean 没问题,可能问题出在那个buylist 类
package buylist;

public class buylist
{public String TITLE;
public int id;
public int number;
public String PRICE;
public String ISBN;
}
运行后显示如下:

HTTP Status 500 -


type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

Generated servlet error:
Syntax error, insert "}" to complete Block

Generated servlet error:
Syntax error on token "}", delete this token

Generated servlet error:
Syntax error, insert "}" to complete ClassBody


	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

org.apache.jasper.JasperException: Unable to compile class for JSP

Generated servlet error:
Syntax error, insert "}" to complete Block

Generated servlet error:
Syntax error on token "}", delete this token

Generated servlet error:
Syntax error, insert "}" to complete ClassBody


	org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
	org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
	org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:409)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.15 logs.


Apache Tomcat/5.5.15

搜索更多相关主题的帖子: 购物车 String ISBN 代码 
2006-06-04 16:16
yangwudong
Rank: 3Rank: 3
等 级:新手上路
威 望:7
帖 子:244
专家分:0
注 册:2005-8-18
收藏
得分:0 
少了一个括号啊!自己找找,用ide工具

别做程序了,给你们一个赚钱的秘诀。做豆腐;if 做硬了 then 卖豆腐干;if 做稀了 then 卖豆腐花;if 太稀了 then 卖豆浆;if 豆腐卖不动了放几天 then 卖臭豆腐; else if 还卖不动放坏了 then 卖腐乳;
2006-06-05 11:09
binbinwu
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-5-26
收藏
得分:0 

谢谢提醒.可是加了个括号后又显示说:shop cannot be resolved or is not a field.这是怎么回事呢?请各位帮我看看,谢谢了.

2006-06-05 20:12
快速回复:为何我的购物车代码用不了?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.059498 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved