購物車網站源碼
① 求JSP簡單購物網站,有簡單的SQL資料庫,有用戶登錄、購物車模塊,有查詢模塊就可以,必須可以運行
JSP 購物車源碼:
response.setContentType("text/html;charset=utf-8");
PrintWriter out = response.getWriter();
HttpSession session=request.getSession(false);
RequestDispatcher dispatcher;
// 如果session不存在,則轉向/ch04/books.jsp
if(session==null){
dispatcher=request.getRequestDispatcher("/ch04/books.jsp");
dispatcher.forward(request, response);
}
BookBean book=(BookBean)session.getAttribute("bookToAdd");
// 取出購物車
Map cart=(Map)session.getAttribute("cart");
// 如果不存在,則創建 if(cart==null){
cart=new HashMap();
session.setAttribute("cart", cart);
}
// 判斷書籍是否在購物車中
CartItemBean cartItem=(CartItemBean)cart.get(book.getISBN());
// 如果書籍在購物車中,則更新其數量
// 否則,創建一個條目到Map中
if(cartItem!=null){
cartItem.setQuantity(cartItem.getQuantity()+1);
}
else{
cart.put(book.getISBN(), new CartItemBean(book,1));
}
dispatcher=request.getRequestDispatcher("/ch04/viewCart.jsp");
dispatcher.forward(request, response);
如果對您有幫助,請記得採納為滿意答案,謝謝!祝您生活愉快!
② 完整的購物車系統源代碼
我是用mcmore購物商城系統,資料庫跟你一樣,是MySQL,Java開發的,要不你去官網看看吧,在這說不清楚。
③ php 外貿購物車源碼,急!
淘寶搜關鍵字 PHP外貿網站源碼加本地測試