cart_add.jsp~13~

来自「JAVA诚信网络购物中心源码」· JSP~13~ 代码 · 共 31 行

JSP~13~
31
字号
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.util.*"%>
<%@ page import="com.domain.SellGoodsForm"%>
<%
int goodsID=Integer.parseInt(request.getParameter("goodsId"));
float goodsPrice=Float.parseFloat(request.getParameter("price"));
SellGoodsForm sellGoodsForm=new SellGoodsForm();
sellGoodsForm.ID=goodsID;
sellGoodsForm.price=goodsPrice;
sellGoodsForm.number=1;
boolean flag=true;
Vector cart=(Vector)session.getAttribute("cart");
if(cart==null){
cart=new Vector();
}else{
for(int i=0;i<cart.size();i++){
   SellGoodsForm form=(SellGoodsForm)cart.elementAt(i);
   if(form.ID==sellGoodsForm.ID){
     sellGoodsForm.number++;
     cart.setElementAt(form,i);
     flag=false;
   }
}
}
if(flag)
cartList.add(sellGoodsForm);
out.print("cartList="+cartList);
session.setAttribute("cart",cartList);
out.println("<script language='javascript'>alert('购买商品成功!');window.close();</script>");
%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?