基于javaweb+mysql的jsp+servlet在线商城购物商城服装商城(前台、后台)(java+jsp+servlet+mysql)

这是一个JavaWeb开发的在线商城系统,使用JSP、Servlet和MySQL数据库。功能包括商品分类展示、搜索、用户注册登录、购物车、订单处理和后台管理。系统还支持管理员查看和管理用户、商品、评论和订单等信息。
摘要由CSDN通过智能技术生成

基于javaweb+mysql的jsp+servlet在线商城购物商城服装商城(前台、后台)(java+jsp+servlet+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

在线商城,实现了商城的基本功能

如分类展示商品信息、搜索商品信息、用户注册登录、添加商品到购物车、提交订单、个人中心查看订单、留言板留言等

管理员登录后台后可以查看管理用户信息、商品分类信息、商品信息、新闻信息、留言信息、订单信息等。

商城模板通用,可修改为任意商城,如手机商城、鲜花商城等等

后台管理员

前台用户

技术框架

CSS JavaScript JSP Servlet JDBC MySQL

基于javaweb+mysql的JSP+Servlet在线商城购物商城服装商城(前台、后台)(java+jsp+servlet+mysql)

		int pagesize=6;//每页行数
		String spage=req.getParameter("page");
		if(spage!=null){ //如果页面上传递了页数,将当前页数改变掉
			page=Integer.parseInt(spage);
		
		}
		//查出总页数
		ArrayList<EASYBUY_COMMENT> list=EASYBUY_COMMENTDao.selPage(page, pagesize);
		int max_page=EASYBUY_COMMENTDao.getMax(pagesize);
		if(list.size()>0&&max_page>0){ 
			req.setAttribute("list", list);
			//把总页数传递给guestbook.jsp 使用
			req.setAttribute("max_page", max_page);
			//把当前页数传递给guestbook.jsp使用
			req.setAttribute("page", page);
			// 跳
		 	req.getRequestDispatcher("guestbook.jsp").forward(req,resp);
		}else{
			resp.getWriter().print("还没有留言信息哦!");
		}
 
	
	}
 
}
package com.web.shopservlet;

//订单表数据的查询

			ArrayList<eb_shop> list=ESDao.getShop(id);
			req.setAttribute("shoplist",list);
			//req.getRequestDispatcher("shopping.jsp").forward(req, resp);
		}else{
			out.print("<script>");
			out.print("alert('请先登录');");
			out.print("location.href='login.jsp';");
			out.print("</script>");
			out.close();
			return;
		}
		String uid = user.getEU_USER_ID();
		int valid = 1;
		eb_shop sp = new eb_shop(0, p.getEP_FILE_NAME(), p.getEP_NAME(), p.getEP_PRICE(), Integer.parseInt(count), p.getEP_STOCK(), p.getEP_ID(), uid, valid);
		ESDao.insert(sp);
		resp.sendRedirect("ShopSelect");
		//req.getRequestDispatcher("ShopSelect").forward(req, resp);
	}
}
package com.demo.Servlet;

public class SelallServlet extends HttpServlet {
			@Override
			protected void service(HttpServletRequest req, HttpServletResponse resp)
					throws ServletException, IOException {
				req.setCharacterEncoding("utf-8");
				resp.setContentType("text/html;charset=utf-8");
				int page=1; //当前页数
				int pagesize=6;//每页行数
				String spage=req.getParameter("page");
													Integer.parseInt(price), 
													Integer.parseInt(stock), 
													Integer.parseInt(id.split("-")[0]), 
													Integer.parseInt(id.split("-")[1]), 
													fname);
		}
		int count = 0;
		if(p!=null){
			count = EASYBUY_PRODUCTDao.insert(p);
		}
		
		req.getRequestDispatcher("productSelect").forward(req, resp);
		
	}
}
package com.demo.Servlet;

public class SelectProductViewServlet extends HttpServlet {
	@SuppressWarnings("unchecked")
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		
		ArrayList<EASYBUY_PRODUCT_CATEGORY> flist = EASYBUY_PRODUCT_CATEGORYDao.selectFather();
		req.setAttribute("flist", flist);
		ArrayList<EASYBUY_PRODUCT_CATEGORY> clist = EASYBUY_PRODUCT_CATEGORYDao.selectChild();
		req.setAttribute("clist", clist);
		String id = req.getParameter("id");
		HttpSession session = req.getSession();
		//查询最近浏览的商品
		ArrayList<Integer> ids = (ArrayList<Integer>)session.getAttribute("ids");
		if(ids==null){
			ids = new ArrayList<Integer>();
		}
		if(ids.size()>=5){
			ids.remove(0);
		EASYBUY_PRODUCT p = null;
		String pid = req.getParameter("id");
		String count = req.getParameter("count");
		if(pid!=null){
			p = EASYBUY_PRODUCTDao.selectById(Integer.parseInt(pid));
		}
		resp.setContentType("text/html;charset=utf-8");
		PrintWriter out = resp.getWriter();
		HttpSession session = req.getSession();
		EASYBUY_USER user=(EASYBUY_USER)session.getAttribute("name");
		
		if(user!=null){
//			System.out.println("登录好了");
			EASYBUY_USER eu=(EASYBUY_USER)session.getAttribute("name");
			String id=(String)eu.getEU_USER_ID();
			ArrayList<eb_shop> list=ESDao.getShop(id);
			req.setAttribute("shoplist",list);
			//req.getRequestDispatcher("shopping.jsp").forward(req, resp);
		}else{
			out.print("<script>");
			out.print("alert('请先登录');");
			out.print("location.href='login.jsp';");
			out.print("</script>");
			out.close();
			return;
		}
		String uid = user.getEU_USER_ID();
		int valid = 1;
		eb_shop sp = new eb_shop(0, p.getEP_FILE_NAME(), p.getEP_NAME(), p.getEP_PRICE(), Integer.parseInt(count), p.getEP_STOCK(), p.getEP_ID(), uid, valid);
		int epid=p.getEP_ID();
		ESDao.insert(sp);
		resp.sendRedirect("selectProductView?id="+epid);
		
		//req.getRequestDispatcher("selectProductView?id=").forward(req, resp);
	}
}
package com.demo.Servlet;

public class SelallServlet extends HttpServlet {
			@Override
			protected void service(HttpServletRequest req, HttpServletResponse resp)
					throws ServletException, IOException {
				req.setCharacterEncoding("utf-8");
				resp.setContentType("text/html;charset=utf-8");
				int page=1; //当前页数
				int pagesize=6;//每页行数
				String spage=req.getParameter("page");
				ArrayList<EASYBUY_PRODUCT_CATEGORY> flist = EASYBUY_PRODUCT_CATEGORYDao.selectFather();
				req.setAttribute("flist", flist);
				ArrayList<EASYBUY_PRODUCT_CATEGORY> clist = EASYBUY_PRODUCT_CATEGORYDao.selectChild();
				req.setAttribute("clist", clist);
				if(spage!=null){ //如果页面上传递了页数,将当前页数改变掉
					page=Integer.parseInt(spage);
				}
 
				//查出总页数
				
				ArrayList<EASYBUY_COMMENT> list=EASYBUY_COMMENTDao.selPage(page, pagesize);
				int max_page=EASYBUY_COMMENTDao.getMax(pagesize);
				if(list.size()>0&&max_page>0){ 
					req.setAttribute("list", list);
					//把总页数传递给guestbook.jsp 使用
					req.setAttribute("max_page", max_page);
					//把当前页数传递给guestbook.jsp使用
					req.setAttribute("page", page);
					// 跳
				 	req.getRequestDispatcher("guestbook.jsp").forward(req,resp);
				}else{
					req.setAttribute("list", list);
					//把总页数传递给guestbook.jsp 使用
					req.setAttribute("max_page", max_page);
					//把当前页数传递给guestbook.jsp使用
					req.setAttribute("page", page);
					// 跳
				 	req.getRequestDispatcher("guestbook.jsp").forward(req,resp);
				}
				
@Override
protected void service(HttpServletRequest arg0, HttpServletResponse arg1)
		throws ServletException, IOException {
	arg1.setContentType("text/html;charset=utf-8");
	PrintWriter out=arg1.getWriter();
	EncodeUtil.encode(arg0);
	HttpSession session=arg0.getSession();
	EASYBUY_USER list=(EASYBUY_USER)session.getAttribute("name");
	//用户id
	String id=list.getEU_USER_ID();
	//用户姓名
	String name=list.getEU_USER_NAME();
	//用户地址
	String address=list.getEU_ADDRESS();
	//总价钱
	String price=arg0.getParameter("jstext");
	
	//商品id
	String [] EP_ID=arg0.getParameterValues("spID");
	//购买数量
	String [] quantity=arg0.getParameterValues("number");
	//商品单价
	String [] sPPrice=arg0.getParameterValues("sPPrice");
	
	//购买后对商品表的库存进行修改
	for(int i=0;i<EP_ID.length;i++){
		int count5=ESDao.updateStock(Integer.parseInt(quantity[i]),Integer.parseInt(EP_ID[i]));
	}
	//商品单个总价
	int [] pprice=new int[EP_ID.length];
	for(int i=0;i<EP_ID.length;i++){
		pprice[i]=Integer.parseInt(quantity[i])*Integer.parseInt(sPPrice[i]);
	} 
	/得到序列
	//往订单表里添加数据
	int count=ESDao.insertDD(id, name, address,Integer.parseInt(price));
	int getSequenceId=ESDao.getSequenceId();
	//循环往订单详情添加
	for(int i=0;i<EP_ID.length;i++){
		EASYBUY_ORDER_DETAIL eod=new EASYBUY_ORDER_DETAIL(1,getSequenceId,Integer.parseInt(EP_ID[i]),Integer.parseInt(quantity[i]),pprice[i]);
		int count2=ESDao.eodInsert(eod);
	}
	
	
	
	// 开单后,修改购物车
	String [] esID=arg0.getParameterValues("esID");
	for(int i=0;i<esID.length;i++){
		int count3 =ESDao.esdelete(Integer.parseInt(esID[i]));
	}
	/
	if(count>0){
	@SuppressWarnings("unchecked")
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		
		ArrayList<EASYBUY_PRODUCT_CATEGORY> flist = EASYBUY_PRODUCT_CATEGORYDao.selectFather();
		req.setAttribute("flist", flist);
		ArrayList<EASYBUY_PRODUCT_CATEGORY> clist = EASYBUY_PRODUCT_CATEGORYDao.selectChild();
		req.setAttribute("clist", clist);
		String id = req.getParameter("id");
		HttpSession session = req.getSession();
		//查询最近浏览的商品
		ArrayList<Integer> ids = (ArrayList<Integer>)session.getAttribute("ids");
		if(ids==null){
			ids = new ArrayList<Integer>();
		}
		if(ids.size()>=5){
			ids.remove(0);
		}
		//System.out.println(!ids.contains(Integer.parseInt(id)));
		if(id!=null&&(!ids.contains(Integer.parseInt(id)))){
			ids.add(Integer.parseInt(id));
		}
		session.setAttribute("ids", ids);
		ids = (ArrayList<Integer>) session.getAttribute("ids");
		if(ids!=null){
			ArrayList<EASYBUY_PRODUCT> lastlylist = EASYBUY_PRODUCTDao.selectById(ids);
			req.setAttribute("lastlylist", lastlylist);
		}
		//查询商品
		EASYBUY_PRODUCT p = null;
		if(id!=null){
			p = EASYBUY_PRODUCTDao.selectById(Integer.parseInt(id));
		}
		req.setAttribute("p", p);
		req.getRequestDispatcher("product-view.jsp").forward(req, resp);
	}
}
package com.demo.Servlet;

		}
		req.setAttribute("p", p);
		req.getRequestDispatcher("product-view.jsp").forward(req, resp);
	}
}
package com.demo.Servlet;

public class LoginServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		String username=req.getParameter("userName");
		String passWord=req.getParameter("passWord");
		String veryCode=req.getParameter("veryCode");
		resp.setContentType("text/html;charset=utf-8");
		HttpSession session = req.getSession();
		//获得系统生成的验证码
		String sysCode = (String)session.getAttribute("syscode");
		int count=EASYBUY_USERDao.selectByNM(username, passWord);
		EASYBUY_USER user=EASYBUY_USERDao.selectAdmin(username, passWord);
		if(sysCode.equals(veryCode)){
			if(count>0){
				session.setAttribute("name", user);
				if(user.getEU_STATUS()==2){
					//System.out.println(user.getEU_STATUS());
					//resp.sendRedirect("manage/index.jsp");
					resp.sendRedirect("manage/index.jsp");
				}else{
					resp.sendRedirect("indexSelect");
			
			Color c=new Color(red,green,blue);
			g.setColor(c);
			int num=rand.nextInt(10);
			code+=num;
			g.drawString(num+"", i*20+20, 49);
		}
		
		HttpSession session=req.getSession();
		session.setAttribute("syscode", code);
		
		ServletOutputStream out=resp.getOutputStream();
		ImageIO.write(img, "jpg", out);
		
		
	}
}
package com.demo.Servlet;

public class UseraddServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
	EncodeUtil.encode(req);
	resp.setContentType("text/html;charset=utf-8");
	
	String username=req.getParameter("userName");
	String name=req.getParameter("name");
	String pwd=req.getParameter("passWord");
	String sex=req.getParameter("sex");
//	String birthyear=request.getParameter("birthyear");
//	String birthmonth=request.getParameter("birthmonth");
//	String birthday=request.getParameter("birthday");
	
					req.setAttribute("max_page", max_page);
					//把当前页数传递给guestbook.jsp使用
					req.setAttribute("page", page);
					// 跳
				 	req.getRequestDispatcher("guestbook.jsp").forward(req,resp);
				}else{
					req.setAttribute("list", list);
					//把总页数传递给guestbook.jsp 使用
					req.setAttribute("max_page", max_page);
					//把当前页数传递给guestbook.jsp使用
					req.setAttribute("page", page);
					// 跳
				 	req.getRequestDispatcher("guestbook.jsp").forward(req,resp);
				}
				
			
			}
		 
		}
  
package com.demo.Servlet;

public class SelectDD extends HttpServlet {

public class SelManage extends HttpServlet {
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		//编码
		req.setCharacterEncoding("utf-8");
		resp.setContentType("text/html;charset=utf-8");
		int page=1; //当前页数
		int pagesize=6;//每页行数
		String spage=req.getParameter("page");
		if(spage!=null){ //如果页面上传递了页数,将当前页数改变掉
			page=Integer.parseInt(spage);
		
		}
		//查出总页数
		ArrayList<EASYBUY_COMMENT> list=EASYBUY_COMMENTDao.selPage(page, pagesize);
		int max_page=EASYBUY_COMMENTDao.getMax(pagesize);
		if(list.size()>0&&max_page>0){ 
			req.setAttribute("list", list);
			//把总页数传递给guestbook.jsp 使用
			req.setAttribute("max_page", max_page);
			//把当前页数传递给guestbook.jsp使用
			req.setAttribute("page", page);
			// 跳
		 	req.getRequestDispatcher("guestbook.jsp").forward(req,resp);
		}else{
			resp.getWriter().print("还没有留言信息哦!");
		}
 
	
	}
 
}
package com.web.shopservlet;

//订单表数据的查询

	resp.setContentType("text/html;charset=utf-8");
	
	String username=req.getParameter("userName");
	String name=req.getParameter("name");
	String pwd=req.getParameter("passWord");
	String sex=req.getParameter("sex");
//	String birthyear=request.getParameter("birthyear");
//	String birthmonth=request.getParameter("birthmonth");
//	String birthday=request.getParameter("birthday");
	
//	String year=birthyear+"-"+birthmonth+"-"+birthday;
	String year=req.getParameter("birthday");
	String email=req.getParameter("email");
	String mobile=req.getParameter("mobile");
	String address=req.getParameter("address");
	
	EASYBUY_USER u=new EASYBUY_USER(username, name, pwd, sex, year, null, email, mobile, address, 1);
	int count=EASYBUY_USERDao.insert(u);
	PrintWriter out=resp.getWriter();
	if(count>0){
		resp.sendRedirect("manage-result.jsp");
	}else{
		out.write("<script>");
		out.write("alert('添加失败');");
		out.write("location.href='user-add.jsp'");
		out.write("</script>");
		out.close();
	}
}
}
package com.demo.Servlet;

				if(user.getEU_STATUS()==2){
					//System.out.println(user.getEU_STATUS());
					//resp.sendRedirect("manage/index.jsp");
					resp.sendRedirect("manage/index.jsp");
				}else{
					resp.sendRedirect("indexSelect");
				}
			}else{
				PrintWriter out = resp.getWriter();
				out.print("<script>");
				out.print("alert('用户名或密码错误');");
				out.print("location.href='login.jsp';");
				out.print("</script>");
				out.close();
			}
		}else{
			PrintWriter out = resp.getWriter();
			out.print("<script>");
			out.print("alert('验证码错误');");
			out.print("location.href='login.jsp';");
			out.print("</script>");
			out.close();
		}
	}
}
package com.demo.Servlet;

public class IndexSelectServlet extends HttpServlet {
	@SuppressWarnings("unchecked")
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		//查询分类数据
		ArrayList<EASYBUY_PRODUCT_CATEGORY> flist = EASYBUY_PRODUCT_CATEGORYDao.selectFather();
		req.setAttribute("flist", flist);
		ArrayList<EASYBUY_PRODUCT_CATEGORY> clist = EASYBUY_PRODUCT_CATEGORYDao.selectChild();
		if(name!=null){
			list = EASYBUY_PRODUCTDao.selectAllByName(name);
			tpage = EASYBUY_PRODUCTDao.totalPageByName(count, name);
			req.setAttribute("title", "搜索商品:"+name);
		} 
		req.setAttribute("list", list);
		//当前页数
		req.setAttribute("cpage", cpage);
		//总页数
		req.setAttribute("tpage", tpage);
		//搜索关键字
		req.setAttribute("search_words", name);
		//父分类
		req.setAttribute("selected_fid", fid);
		req.getRequestDispatcher("product-list.jsp").forward(req, resp);
	}
}
package com.web.shopservlet;

public class gmServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest arg0, HttpServletResponse arg1)
		throws ServletException, IOException {
	arg1.setContentType("text/html;charset=utf-8");
	PrintWriter out=arg1.getWriter();
	EncodeUtil.encode(arg0);
	HttpSession session=arg0.getSession();
	EASYBUY_USER list=(EASYBUY_USER)session.getAttribute("name");
	//用户id
	String id=list.getEU_USER_ID();
	//用户姓名
	String name=list.getEU_USER_NAME();
	//用户地址
	String address=list.getEU_ADDRESS();
	//总价钱
	String price=arg0.getParameter("jstext");
		session.setAttribute("ids", ids);
		ids = (ArrayList<Integer>) session.getAttribute("ids");
		if(ids!=null){
			ArrayList<EASYBUY_PRODUCT> lastlylist = EASYBUY_PRODUCTDao.selectById(ids);
			req.setAttribute("lastlylist", lastlylist);
		}
		//查询商品
		EASYBUY_PRODUCT p = null;
		if(id!=null){
			p = EASYBUY_PRODUCTDao.selectById(Integer.parseInt(id));
		}
		req.setAttribute("p", p);
		req.getRequestDispatcher("product-view.jsp").forward(req, resp);
	}
}
package com.demo.Servlet;

public class LoginServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		String username=req.getParameter("userName");
		String passWord=req.getParameter("passWord");
		String veryCode=req.getParameter("veryCode");
		resp.setContentType("text/html;charset=utf-8");
		HttpSession session = req.getSession();
		//获得系统生成的验证码
		String sysCode = (String)session.getAttribute("syscode");
			green=rand.nextInt(255);
			blue=rand.nextInt(255);
			
			Color c=new Color(red,green,blue);
			g.setColor(c);
			int num=rand.nextInt(10);
			code+=num;
			g.drawString(num+"", i*20+20, 49);
		}
		
		HttpSession session=req.getSession();
		session.setAttribute("syscode", code);
		
		ServletOutputStream out=resp.getOutputStream();
		ImageIO.write(img, "jpg", out);
		
		
	}
}
package com.demo.Servlet;

public class UseraddServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
	EncodeUtil.encode(req);
	resp.setContentType("text/html;charset=utf-8");
	
	String username=req.getParameter("userName");
	String name=req.getParameter("name");
	String pwd=req.getParameter("passWord");
	String sex=req.getParameter("sex");
//	String birthyear=request.getParameter("birthyear");
//	String birthmonth=request.getParameter("birthmonth");
//	String birthday=request.getParameter("birthday");
	
//	String year=birthyear+"-"+birthmonth+"-"+birthday;
	String year=req.getParameter("birthday");
	String email=req.getParameter("email");
	String mobile=req.getParameter("mobile");
	String address=req.getParameter("address");
public class RegisterInServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
	req.setCharacterEncoding("UTF-8");
	String username=req.getParameter("userName");
	String name=req.getParameter("name");
	String rePassWord=req.getParameter("rePassWord");
	String sex=req.getParameter("sex");
	String year=req.getParameter("birthday");
	String email=req.getParameter("email");
	String mobile=req.getParameter("mobile");
	String address=req.getParameter("address");
	String veryCode=req.getParameter("veryCode");
	
	HttpSession session = req.getSession();
	//获得系统生成的验证码
	String sysCode = (String)session.getAttribute("syscode");
	EASYBUY_USER u=new EASYBUY_USER(username, name, rePassWord, sex, year, null, email, mobile, address, 1);
	int count=EASYBUY_USERDao.insert(u);
	PrintWriter out=resp.getWriter();
	if(sysCode.equals(veryCode)){
		if(count>0){
			resp.sendRedirect("reg-result.jsp");
		}else{
			out.write("<script>");
			out.write("alert('register error');");
			out.write("location.href='register.jsp'");
			out.write("</script>");
			out.close();
		}
	}
	
	
	}
}
package com.demo.Servlet;

			String id=(String)eu.getEU_USER_ID();
			ArrayList<eb_shop> list=ESDao.getShop(id);
			req.setAttribute("shoplist",list);
			//req.getRequestDispatcher("shopping.jsp").forward(req, resp);
		}else{
			out.print("<script>");
			out.print("alert('请先登录');");
			out.print("location.href='login.jsp';");
			out.print("</script>");
			out.close();
			return;
		}
		String uid = user.getEU_USER_ID();
		int valid = 1;
		eb_shop sp = new eb_shop(0, p.getEP_FILE_NAME(), p.getEP_NAME(), p.getEP_PRICE(), Integer.parseInt(count), p.getEP_STOCK(), p.getEP_ID(), uid, valid);
		ESDao.insert(sp);
		resp.sendRedirect("ShopSelect");
		//req.getRequestDispatcher("ShopSelect").forward(req, resp);
	}
}
package com.demo.Servlet;

public class SelallServlet extends HttpServlet {
			@Override
			protected void service(HttpServletRequest req, HttpServletResponse resp)
					throws ServletException, IOException {
				req.setCharacterEncoding("utf-8");
				resp.setContentType("text/html;charset=utf-8");
				int page=1; //当前页数
				int pagesize=6;//每页行数
				String spage=req.getParameter("page");
				ArrayList<EASYBUY_PRODUCT_CATEGORY> flist = EASYBUY_PRODUCT_CATEGORYDao.selectFather();
				req.setAttribute("flist", flist);
				ArrayList<EASYBUY_PRODUCT_CATEGORY> clist = EASYBUY_PRODUCT_CATEGORYDao.selectChild();
				req.setAttribute("clist", clist);
				if(spage!=null){ //如果页面上传递了页数,将当前页数改变掉
	}
}
package com.demo.Servlet;

public class ShopAddServlet extends HttpServlet {
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
//		  es_id           NUMBER primary key not null,--id
//		  es_ep_file_name NVARCHAR2(30),--图片名称
//		  es_ep_name      NVARCHAR2(30),--商品名
//		  es_ep_price     NUMBER,--商品单价
//		  es_eod_quantity NUMBER,--购买数量
//		  es_ep_stock     NUMBER,--商品库存
//		  es_ep_id        NUMBER,--商品id
//		  es_EU_USER_ID   NVARCHAR2(30),--用户id
//		  es_valid	  NUMBER --是否结账,1未结账,2已结账
		EASYBUY_PRODUCT p = null;
		String pid = req.getParameter("id");
		String count = req.getParameter("count");
		if(pid!=null){
			p = EASYBUY_PRODUCTDao.selectById(Integer.parseInt(pid));
		}
		resp.setContentType("text/html;charset=utf-8");
		PrintWriter out = resp.getWriter();
		HttpSession session = req.getSession();
		EASYBUY_USER user=(EASYBUY_USER)session.getAttribute("name");
		
		if(user!=null){
//			System.out.println("登录好了");
			EASYBUY_USER eu=(EASYBUY_USER)session.getAttribute("name");
			String id=(String)eu.getEU_USER_ID();
		resp.sendRedirect("ShopSelect");
		//req.getRequestDispatcher("ShopSelect").forward(req, resp);
	}
}
package com.demo.Servlet;

public class SelallServlet extends HttpServlet {
			@Override
			protected void service(HttpServletRequest req, HttpServletResponse resp)
					throws ServletException, IOException {
				req.setCharacterEncoding("utf-8");
				resp.setContentType("text/html;charset=utf-8");
				int page=1; //当前页数
				int pagesize=6;//每页行数
				String spage=req.getParameter("page");
				ArrayList<EASYBUY_PRODUCT_CATEGORY> flist = EASYBUY_PRODUCT_CATEGORYDao.selectFather();
				req.setAttribute("flist", flist);
				ArrayList<EASYBUY_PRODUCT_CATEGORY> clist = EASYBUY_PRODUCT_CATEGORYDao.selectChild();
				req.setAttribute("clist", clist);
				if(spage!=null){ //如果页面上传递了页数,将当前页数改变掉
					page=Integer.parseInt(spage);
				}
 
				//查出总页数
				
				ArrayList<EASYBUY_COMMENT> list=EASYBUY_COMMENTDao.selPage(page, pagesize);
				int max_page=EASYBUY_COMMENTDao.getMax(pagesize);
				if(list.size()>0&&max_page>0){ 
					req.setAttribute("list", list);
					//把总页数传递给guestbook.jsp 使用
					req.setAttribute("max_page", max_page);
					//把当前页数传递给guestbook.jsp使用
					req.setAttribute("page", page);
					// 跳
				 	req.getRequestDispatcher("guestbook.jsp").forward(req,resp);
		Files fs = su.getFiles();//获得所有文件
		File f = fs.getFile(0);//获得上传的文件
		String fname = f.getFileName();//获得文件名
		try {
			su.save("images/product");//保存图片到指定位置
		} catch (SmartUploadException e) {
			e.printStackTrace();
		}
		Request req1 = su.getRequest();
		String id = req1.getParameter("id");
		String pname = req1.getParameter("productName");
		String pid = req1.getParameter("parentId");
		String price = req1.getParameter("productPrice");
		String desc = req1.getParameter("productDesc");
		String stock = req1.getParameter("productStock");
		EASYBUY_PRODUCT p = new EASYBUY_PRODUCT(Integer.parseInt(id), 
												pname, 
												desc, 
												Integer.parseInt(price), 
												Integer.parseInt(stock), 
												Integer.parseInt(pid.split("-")[0]), 
												Integer.parseInt(pid.split("-")[1]), 
												fname);
		int count = 0;
		if(p!=null){
			count = EASYBUY_PRODUCTDao.update(p);
		}
		
		req.getRequestDispatcher("productSelect").forward(req, resp);
		
	}
}
package com.demo.Servlet;

		req.setAttribute("list", list);
		//当前页数
		req.setAttribute("cpage", cpage);
		//总页数
		req.setAttribute("tpage", tpage);
		//搜索关键字
		req.setAttribute("search_words", name);
		//父分类
		req.setAttribute("selected_fid", fid);
		req.getRequestDispatcher("product-list.jsp").forward(req, resp);
	}
}
package com.web.shopservlet;

public class gmServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest arg0, HttpServletResponse arg1)
		throws ServletException, IOException {
	arg1.setContentType("text/html;charset=utf-8");
	PrintWriter out=arg1.getWriter();
	EncodeUtil.encode(arg0);
	HttpSession session=arg0.getSession();
	EASYBUY_USER list=(EASYBUY_USER)session.getAttribute("name");
	//用户id
	String id=list.getEU_USER_ID();
	//用户姓名
	String name=list.getEU_USER_NAME();
package com.demo.Servlet;

public class DoProductUpdateServlet extends HttpServlet {
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
SmartUpload su = new SmartUpload();
		
		su.initialize(this.getServletConfig(), req, resp);
		
		try {
			su.upload();
		} catch (SmartUploadException e) {
			e.printStackTrace();
		}
		
		Files fs = su.getFiles();//获得所有文件
		File f = fs.getFile(0);//获得上传的文件
		String fname = f.getFileName();//获得文件名
		try {
			su.save("images/product");//保存图片到指定位置
		} catch (SmartUploadException e) {
			e.printStackTrace();
		}
		Request req1 = su.getRequest();
		String id = req1.getParameter("id");
		String pname = req1.getParameter("productName");
		String pid = req1.getParameter("parentId");
		String price = req1.getParameter("productPrice");
		String desc = req1.getParameter("productDesc");
		String stock = req1.getParameter("productStock");
		EASYBUY_PRODUCT p = new EASYBUY_PRODUCT(Integer.parseInt(id), 
												pname, 

public class gmServlet extends HttpServlet {
@Override
protected void service(HttpServletRequest arg0, HttpServletResponse arg1)
		throws ServletException, IOException {
	arg1.setContentType("text/html;charset=utf-8");
	PrintWriter out=arg1.getWriter();
	EncodeUtil.encode(arg0);
	HttpSession session=arg0.getSession();
	EASYBUY_USER list=(EASYBUY_USER)session.getAttribute("name");
	//用户id
	String id=list.getEU_USER_ID();
	//用户姓名
	String name=list.getEU_USER_NAME();
	//用户地址
	String address=list.getEU_ADDRESS();
	//总价钱
	String price=arg0.getParameter("jstext");
	
	//商品id
	String [] EP_ID=arg0.getParameterValues("spID");
	//购买数量
	String [] quantity=arg0.getParameterValues("number");
	//商品单价
	String [] sPPrice=arg0.getParameterValues("sPPrice");
	
	//购买后对商品表的库存进行修改
	for(int i=0;i<EP_ID.length;i++){
		int count5=ESDao.updateStock(Integer.parseInt(quantity[i]),Integer.parseInt(EP_ID[i]));
	}
	//商品单个总价
	int [] pprice=new int[EP_ID.length];
	for(int i=0;i<EP_ID.length;i++){
		pprice[i]=Integer.parseInt(quantity[i])*Integer.parseInt(sPPrice[i]);
	} 
	/得到序列
	//往订单表里添加数据
	int count=ESDao.insertDD(id, name, address,Integer.parseInt(price));
	int getSequenceId=ESDao.getSequenceId();
	//循环往订单详情添加
	for(int i=0;i<EP_ID.length;i++){
		EASYBUY_ORDER_DETAIL eod=new EASYBUY_ORDER_DETAIL(1,getSequenceId,Integer.parseInt(EP_ID[i]),Integer.parseInt(quantity[i]),pprice[i]);
		int count2=ESDao.eodInsert(eod);
			out.print("<script>");
			out.print("alert('修改失败');");
			out.print("location.href='user'");
			out.print("</script>");
			out.close();
		}
	}
}
package com.demo.manage;

 

public class UpManage extends HttpServlet {
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		int id=Integer.parseInt(request.getParameter("orderId"));
		String name=request.getParameter("name");
		String replyContent=request.getParameter("replyContent");
		String Content=request.getParameter("Content");
		Date date=new Date();
		System.out.println(Content);
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String replyTime=sdf.format(date);
		EASYBUY_COMMENT comment=new EASYBUY_COMMENT(id,Content,replyTime,replyContent,replyTime,name);
	 
		//System.out.println(id+"--"+content+"--"+replyTime+"--"+replyContent+"--"+name);
				int page=1; //当前页数
				int pagesize=6;//每页行数
				String spage=req.getParameter("page");
				ArrayList<EASYBUY_PRODUCT_CATEGORY> flist = EASYBUY_PRODUCT_CATEGORYDao.selectFather();
				req.setAttribute("flist", flist);
				ArrayList<EASYBUY_PRODUCT_CATEGORY> clist = EASYBUY_PRODUCT_CATEGORYDao.selectChild();
				req.setAttribute("clist", clist);
				if(spage!=null){ //如果页面上传递了页数,将当前页数改变掉
					page=Integer.parseInt(spage);
				}
 
				//查出总页数
				
				ArrayList<EASYBUY_COMMENT> list=EASYBUY_COMMENTDao.selPage(page, pagesize);
				int max_page=EASYBUY_COMMENTDao.getMax(pagesize);
				if(list.size()>0&&max_page>0){ 
					req.setAttribute("list", list);
					//把总页数传递给guestbook.jsp 使用
					req.setAttribute("max_page", max_page);
					//把当前页数传递给guestbook.jsp使用
					req.setAttribute("page", page);
					// 跳
				 	req.getRequestDispatcher("guestbook.jsp").forward(req,resp);
				}else{
					req.setAttribute("list", list);
					//把总页数传递给guestbook.jsp 使用
					req.setAttribute("max_page", max_page);
					//把当前页数传递给guestbook.jsp使用
					req.setAttribute("page", page);
					// 跳
				 	req.getRequestDispatcher("guestbook.jsp").forward(req,resp);
				}
				
			
			}
		 
		}
  
package com.demo.Servlet;

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值