• 大小: 1.61MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-10-04
  • 语言: Java
  • 标签: 书城  

资源简介

自己收藏的一个网上书城的项目,数据库什么的,都齐全,肯定是能跑的

资源截图

代码片段和文件信息

package net.vicp.zyl_me.control;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.vicp.zyl_me.model.CartHandler;
import net.vicp.zyl_me.model.GoodsBean;

public class CartServlet extends HttpServlet {

/**
 * The doGet method of the servlet. 

 * 
 * This method is called when a form has its tag value method equals to get.
 * 
 * @param request
 *            the request send by the client to the server
 * @param response
 *            the response send by the server to the client
 * @throws ServletException
 *             if an error occurred
 * @throws IOException
 *             if an error occurred
 */
public void doGet(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {

response.setContentType(“text/html“);
response.setCharacterEncoding(“utf-8“);
String action = request.getParameter(“action“);
String id = request.getParameter(“id“);
HttpSession session = request.getSession();
CartHandler cartHandler = (CartHandler) session.getAttribute(“cartHandler“);
// 保持只有一个购物车【CartHandler]
if (cartHandler == null) {
// 说明第一次购物
cartHandler = new CartHandler();
request.getSession().setAttribute(“cartHandler“ cartHandler);
}
if (id != null)// 不是查看,是添加商品或删除商品
{
if (“del“.equals(action)) {
cartHandler.removeGoodsById(id);
} else if (“add“.equals(action)) {
cartHandler.AddGoods1QuantityById(id);
} else if (“sub“.equals(action)) {
cartHandler.SubGoods1QuantityById(id);
} else// 添加新货物
{
cartHandler.addNewGoods(id “1“);
}
}
ArrayList cart = cartHandler.getGoods();
ArrayList goods = new ArrayList();
for(int i = 0;i < cart.size();i++)
goods.add(Integer.parseInt(cartHandler.getGoodsCountById(cart.get(i).getGoodsid()+““)));
request.setAttribute(“cart“ cart);
request.setAttribute(“goodsNums“goods);
request.getRequestDispatcher(“cart.jsp“).forward(request response);
}

/**
 * The doPost method of the servlet. 

 * 
 * This method is called when a form has its tag value method equals to
 * post.
 * 
 * @param request
 *            the request send by the client to the server
 * @param response
 *            the response send by the server to the client
 * @throws ServletException
 *             if an error occurred
 * @throws IOException
 *             if an error occurred
 */
public void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {

doGet(request response);
}

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-05-27 09:21  bookstore-master\
     文件         840  2015-05-27 09:21  bookstore-master\.classpath
     文件           8  2015-05-27 09:21  bookstore-master\.gitignore
     文件        1408  2015-05-27 09:21  bookstore-master\.project
     目录           0  2015-05-27 09:21  bookstore-master\.settings\
     文件         522  2015-05-27 09:21  bookstore-master\.settings\.jsdtscope
     文件         364  2015-05-27 09:21  bookstore-master\.settings\org.eclipse.jdt.core.prefs
     文件         478  2015-05-27 09:21  bookstore-master\.settings\org.eclipse.wst.common.component
     文件         414  2015-05-27 09:21  bookstore-master\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2015-05-27 09:21  bookstore-master\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2015-05-27 09:21  bookstore-master\.settings\org.eclipse.wst.jsdt.ui.superType.name
     文件         108  2015-05-27 09:21  bookstore-master\README.md
     文件           0  2015-05-27 09:21  bookstore-master\README.md~
     目录           0  2015-05-27 09:21  bookstore-master\WebRoot\
     目录           0  2015-05-27 09:21  bookstore-master\WebRoot\meta-INF\
     文件          39  2015-05-27 09:21  bookstore-master\WebRoot\meta-INF\MANIFEST.MF
     目录           0  2015-05-27 09:21  bookstore-master\WebRoot\WEB-INF\
     目录           0  2015-05-27 09:21  bookstore-master\WebRoot\WEB-INF\lib\
     文件      872303  2015-05-27 09:21  bookstore-master\WebRoot\WEB-INF\lib\mysql-connector-java-5.1.27-bin.jar
     文件        2362  2015-05-27 09:21  bookstore-master\WebRoot\WEB-INF\web.xml
     文件        1679  2015-05-27 09:21  bookstore-master\WebRoot\about.jsp
     文件        4348  2015-05-27 09:21  bookstore-master\WebRoot\books.jsp
     文件        4224  2015-05-27 09:21  bookstore-master\WebRoot\cart.jsp
     文件        2494  2015-05-27 09:21  bookstore-master\WebRoot\contact.jsp
     文件        2690  2015-05-27 09:21  bookstore-master\WebRoot\content-left.jsp
     文件        2595  2015-05-27 09:21  bookstore-master\WebRoot\content-right.jsp
     目录           0  2015-05-27 09:21  bookstore-master\WebRoot\css\
     文件        1265  2015-05-27 09:21  bookstore-master\WebRoot\css\about.css
     文件        1292  2015-05-27 09:21  bookstore-master\WebRoot\css\books.css
     文件        1815  2015-05-27 09:21  bookstore-master\WebRoot\css\cart.css
     文件        2897  2015-05-27 09:21  bookstore-master\WebRoot\css\contact.css
............此处省略126个文件信息

评论

共有 条评论