⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cart_add.jsp~15~

📁 JAVA诚信网络购物中心源码
💻 JSP~15~
字号:
<%@ 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)
cart.add(sellGoodsForm);
out.print("cartList="+cart);
session.setAttribute("cart",cart);
out.println("<script language='javascript'>alert('购买商品成功!');window.close();</script>");
%>

⌨️ 快捷键说明

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