——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
在线商城,实现了商城的基本功能
如分类展示商品信息、搜索商品信息、用户注册登录、添加商品到购物车、提交订单、个人中心查看订单、留言板留言等
管理员登录后台后可以查看管理用户信息、商品分类信息、商品信息、新闻信息、留言信息、订单信息等。
商城模板通用,可修改为任意商城,如手机商城、鲜花商城等等

后台管理员






前台用户










技术框架
CSS JavaScript JSP Servlet JDBC MySQL
基于javaweb的JSP+Servlet在线商城购物商城服装商城(前台、后台)(java+jsp+servlet+mysql)
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| 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;
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");
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| 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); } if(id!=null&&(!ids.contains(Integer.parseInt(id)))){
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| 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){ out.print("<script>"); out.print("alert('购物成功');"); out.print("location.href='shopping-result.jsp';"); out.print("</script>"); out.close(); }else{ out.print("<script>"); out.print("alert('购物失败,请重新选择商品');"); out.print("location.href='ShopSelect';"); out.print("</script>"); out.close(); } } } package com.demo.Servlet;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| 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"); String id=list.getEU_USER_ID(); String name=list.getEU_USER_NAME(); String address=list.getEU_ADDRESS(); String price=arg0.getParameter("jstext"); String [] EP_ID=arg0.getParameterValues("spID"); String [] quantity=arg0.getParameterValues("number");
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| public class SelectProductListServlet extends HttpServlet { @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { EncodeUtil.encode(req); 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); HttpSession session = req.getSession(); ArrayList<Integer> ids = (ArrayList<Integer>)session.getAttribute("ids"); if(ids!=null){ ArrayList<EASYBUY_PRODUCT> lastlylist = EASYBUY_PRODUCTDao.selectById(ids); req.setAttribute("lastlylist", lastlylist); } int cpage = 1; int count = 8; String cp = req.getParameter("cp"); if(cp!=null){ cpage = Integer.parseInt(cp); } int tpage = 0; String fid = req.getParameter("fid"); String cid = req.getParameter("cid"); String name = req.getParameter("name"); ArrayList<EASYBUY_PRODUCT> list = null; if(fid==null&&cid==null){ list = EASYBUY_PRODUCTDao.selectAll(cpage, count); req.setAttribute("title", "全部商品"); tpage = EASYBUY_PRODUCTDao.totalPage(count); } if(fid!=null){ int id = Integer.parseInt(fid); list = EASYBUY_PRODUCTDao.selectAllByFid(cpage, count, id); tpage = EASYBUY_PRODUCTDao.totalPageByFid(count, id);
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| 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();
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=052321431205102af
https://javayms.pages.dev?id=052321431205102af