资源简介
自己收藏的一个网上书城的项目,数据库什么的,都齐全,肯定是能跑的
代码片段和文件信息
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.xm
文件 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\me
文件 39 2015-05-27 09:21 bookstore-master\WebRoot\me
目录 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.xm
文件 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个文件信息
相关资源
- 基于ssm网上书城项目系统
- jsp网上书城
- 网上书城项目源码
- 网上书城系统Struts+Hibernate+Mysql
- 北大青鸟学士后网上书城系统代码
- 网上书城jsp+servlet+javabean
- javaweb_网上书城_mvc
- JavaWeb书城项目.zip
- 网上书城javaWeb项目
- jsp+mysql:网上书城
- JavaWeb网上书城项目 界面简洁漂亮 功
- java众望书城网上系统
- javaWEB的网上书城
- 网上书城项目
- 网上书城里面
- web网上书城完整项目附数据库
- 传智书城项目设计源代码
- javaweb 网上书城包含数据库
- 尚硅谷 佟刚 网上书城
- 传智书城前端JSP代码
- 基于ssm的jsp网上书城毕业设计论文+源
- 基于jsp的网上书城系统
- Javaweb课程设计-网上书城.zip
- 基于Javaweb的网上书城教程及源码
- Javaweb-网上书城项目前后端分离,代码
- JavaWeb-day24--网上书城-全部资料.zip
- java网上书城毕业设计(模仿当当网)
- mysql+java 网上书城完整项目和毕设论文
- 网上书城系统java源码
- 传智播客项目资料-网上书城
评论
共有 条评论