JavaWeb毕业设计-蛋糕商城系统(idea可用)

JavaWeb毕业设计-蛋糕商城系统(idea可用),第1张

软件工程课程设计|毕业设计之蛋糕商城系统代码-基于javaweb的蛋糕商城系统-基于jsp的商品销售平台代码

前言

本次文章主要是介绍蛋糕商城系统的功能,系统分为两个角色,管理员,用户

一、系统功能

1.1 开发环境

  • 开发语言:Java
  • 技术:JavaWeb【Servlet】
  • 数据库:MySQL
  • 架构:B/S
  • 源码类型: Web
  • 编译工具:Idea
  • 其他:jdk1.8、Tomcat9.0 、Navicat

1.2 管理员功能

登录,用户管理,商品类目管理,商品管理,节日管理,订单管理,发货

1.3 用户功能

注册,登录,修改密码,输入收货信息,搜索,查看热销商品,查看新品
加入购物车,提交订,收货

二、部分功能展示

☀️首页☀️

JavaWeb毕业设计-蛋糕商城系统(idea可用),第2张

 ☀️商品展示☀️JavaWeb毕业设计-蛋糕商城系统(idea可用),第3张

  ☀️项目结构展示☀️

JavaWeb毕业设计-蛋糕商城系统(idea可用),第4张

三、部分代码设计

3.1.商品推荐

@WebServlet(name = "admin_goods_list",urlPatterns = "/admin/goods_list") public class AdminGoodsListServlet extends HttpServlet { private GoodsService gService = new GoodsService(); /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int type = 0;//推荐类型 if(request.getParameter("type") != null) { type=Integer.parseInt(request.getParameter("type") ) ; } int pageNumber = 1; if(request.getParameter("pageNumber") != null) { try { pageNumber=Integer.parseInt(request.getParameter("pageNumber") ) ; } catch (Exception e) { } } if(pageNumber<=0) pageNumber=1; Page p = gService.getGoodsRecommendPage(type, pageNumber); if(p.getTotalPage()==0) { p.setTotalPage(1); p.setPageNumber(1); } else { if(pageNumber>=p.getTotalPage()+1) { p = gService.getGoodsRecommendPage(type, pageNumber); } } request.setAttribute("p", p); request.setAttribute("type", type); request.getRequestDispatcher("/admin/goods_list.jsp").forward(request, response); }

3.2.商品推荐

@WebServlet("/admin/goods_add") public class AdminGoodsAddServlet extends HttpServlet { private GoodsService gService = new GoodsService(); /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { DiskFileItemFactory factory=new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); try { List<FileItem> list = upload.parseRequest(request); Goods g = new Goods(); for(FileItem item:list) { if(item.isFormField()) { switch(item.getFieldName()) { case "name": g.setName(item.getString("utf-8")); break; case "price": g.setPrice(Integer.parseInt(item.getString("utf-8"))); break; case "intro": g.setIntro(item.getString("utf-8")); break; case "stock": g.setStock(Integer.parseInt(item.getString("utf-8"))); break; case "typeid": g.setTypeid(Integer.parseInt(item.getString("utf-8"))); break; } }else { if(item.getInputStream().available()<=0)continue; String fileName = item.getName(); fileName = fileName.substring(fileName.lastIndexOf(".")); fileName = "/"+new Date().getTime()+fileName; String path = this.getServletContext().getRealPath("/picture")+fileName; System.out.println(path); InputStream in = item.getInputStream(); FileOutputStream out = new FileOutputStream(path); byte[] buffer = new byte[1024]; int len=0; while( (len=in.read(buffer))>0 ) { out.write(buffer); } in.close(); out.close(); item.delete(); switch(item.getFieldName()) { case "cover": g.setCover("/picture"+fileName); break; case "image1": g.setImage1("/picture"+fileName); break; case "image2": g.setImage2("/picture"+fileName); break; } } } gService.insert(g); request.getRequestDispatcher("/admin/goods_list").forward(request, response); } catch (FileUploadException e) { // TODO Auto-generated catch block e.printStackTrace(); } } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); }}

3.3.编辑商品

@WebServlet("/admin/goods_edit") public class AdminGoodsEditServlet extends HttpServlet { private GoodsService gService = new GoodsService(); /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { DiskFileItemFactory factory=new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); try { List<FileItem> list = upload.parseRequest(request); Goods g = new Goods(); int pageNo =1; int type=0; for(FileItem item:list) { if(item.isFormField()) { switch(item.getFieldName()) { case "id": g.setId(Integer.parseInt(item.getString("utf-8"))); break; case "name": g.setName(item.getString("utf-8")); break; case "price": g.setPrice(Float.parseFloat(item.getString("utf-8"))); break; case "intro": g.setIntro(item.getString("utf-8")); break; case "cover": g.setCover(item.getString("utf-8")); break; case "image1": g.setImage1(item.getString("utf-8")); break; case "image2": g.setImage2(item.getString("utf-8")); break; case "stock": g.setStock(Integer.parseInt(item.getString("utf-8"))); break; case "typeid": g.setTypeid(Integer.parseInt(item.getString("utf-8"))); break; case "pageNo": pageNo=Integer.parseInt(item.getString("utf-8")); break; case "type": type = Integer.parseInt(item.getString("utf-8")); break; } }else { if(item.getInputStream().available()<=0)continue; String fileName = item.getName(); fileName = fileName.substring(fileName.lastIndexOf(".")); fileName = "/"+new Date().getTime()+fileName; String path = this.getServletContext().getRealPath("/picture")+fileName; System.out.println(path); InputStream in = item.getInputStream(); FileOutputStream out = new FileOutputStream(path); byte[] buffer = new byte[1024]; int len=0; while( (len=in.read(buffer))>0 ) { out.write(buffer); } in.close(); out.close(); item.delete(); switch(item.getFieldName()) { case "cover": g.setCover("/picture"+fileName); break; case "image1": g.setImage1("/picture"+fileName); break; case "image2": g.setImage2("/picture"+fileName); break; } } } gService.update(g); request.getRequestDispatcher("/admin/goods_list?pageNo="+pageNo+"&type="+type).forward(request, response); } catch (FileUploadException e) { // TODO Auto-generated catch block e.printStackTrace(); } } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); }}

总结

获取源码 https://www.alipan.com/s/rkXfhP8suVn 

感谢或求助

如果内容对你的学习有帮助的话不妨感谢一杯cafe

如果你需要我远程帮你的话请赞助30以上

JavaWeb毕业设计-蛋糕商城系统(idea可用),第5张

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/13518130.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-12-31
下一篇 2024-01-03

发表评论

登录后才能评论

评论列表(0条)

保存