免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2552 | 回复: 0
打印 上一主题 下一主题

jsp bean 问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-11-30 01:03 |只看该作者 |倒序浏览
调用bean时错误!
An error occurred at line: 22 in the jsp file: /bookshop/addtocart.jsp
cartBean cannot be resolved to a type
19:   double d_unitprice=Double.parseDouble(s_price);
20:   double d_subtotal=i_ordernum*d_unitprice;
21:   d_subtotal=Math.round(d_subtotal*100)/100.00;
22:   cartBean cbean=new cartBean();
23:   cbean.bookid=s_bookid;
24:   cbean.bookname=s_bookname;
25:   cbean.publish=s_publish;

An error occurred at line: 41 in the jsp file: /bookshop/addtocart.jsp
cartBean cannot be resolved to a type
38:     String s_flag="false";
39:     it=c_cart.iterator();
40:     while(it.hasNext()){
41:       cartBean cb=(cartBean)(it.next());
42:       if(cb.bookid.equals(s_bookid)){
43:         cb.ordernum++;
44:         cb.subtotal+=cb.unitprice;

//cartBean.java源码
package bean;
public class cartBean {
  public String bookid="";
  public String bookname="";
  public String publish="";
  public int ordernum=0;
  public double unitprice=0.0;
  public double subtotal=0.0;       
}
//addtocart.jsp源码
<%@ page contentType="text/html; charset=GB2312" %>
<%@ page import="bean.*,java.util.*"%>
<%@ page import="java.sql.*"%>
<%
  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver";
  Connection conn = DriverManager.getConnection

("jdbcdbc:bookshoplk","sa","";
  Statement stmt=conn.createStatement

(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
  ResultSet rs=null;
%>
<%
  String s_bookid=request.getParameter("bookid";
  rs=stmt.executeQuery("select * from book  left join publisher on

book.publisherid=publisher.publisherid  where bookid='"+s_bookid+"'";
  rs.next();
  String s_bookname=rs.getString("bookname";
  String s_author=rs.getString("author";
  String s_price=rs.getString("price";
  String s_publish=rs.getString("name";
  int i_ordernum=1;
  double d_unitprice=Double.parseDouble(s_price);
  double d_subtotal=i_ordernum*d_unitprice;
  d_subtotal=Math.round(d_subtotal*100)/100.00;
  cartBean cbean=new cartBean();
  cbean.bookid=s_bookid;
  cbean.bookname=s_bookname;
  cbean.publish=s_publish;
  cbean.ordernum=i_ordernum;
  cbean.unitprice=d_unitprice;
  cbean.subtotal=d_subtotal;
  Collection c_cart=(Collection)session.getAttribute("cart";
  Iterator it=null;
%>
<%
  if(c_cart==null){
    c_cart= new Vector();
    c_cart.add(cbean);
    session.setAttribute("cart",c_cart);
  }else{
    String s_flag="false";
    it=c_cart.iterator();
    while(it.hasNext()){
      cartBean cb=(cartBean)(it.next());
      if(cb.bookid.equals(s_bookid)){
        cb.ordernum++;
        cb.subtotal+=cb.unitprice;
        s_flag="true";
      }//if end       
    }//while end
    if(s_flag.equals("false"){
      c_cart.add(cbean);
    }
  }//else end
  response.sendRedirect("shoppingcart.jsp");
%>

[ 本帖最后由 Fireshare 于 2008-11-30 01:04 编辑 ]
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP