——————————DescriptionStart——————————
运行环境 Java≥8、MySQL≥5.7、Tomcat≥8
开发工具 eclipse/idea/myeclipse/sts等均可配置运行
适用 课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的JSP+Servlet早餐外卖店管理系统(java+jsp+javascript+servlet+mysql)
项目介绍
本系统分为前后台,分为普通用户和管理员两种角色;
管理员角色包含以下功能: 管理员登录,用户管理,分类管理,菜品管理,订单管理等功能。
用户角色包含以下功能: 用户点餐首页,用户首页,查看菜品详情,提交订单,查看订单等功能。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否Maven项目:否;
技术栈
JSP+CSS+JavaScript+java+servlet+mysql
使用说明
使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中src/com/hr/dao/Basedao.java配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入http://localhost:8080/ 登录 管理员账号/密码:admin/admin 用户账号/密码:user/123456
——————————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 43 44 45 46 // 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(); 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;
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 req.setAttribute("clist" , clist); ArrayList<EASYBUY_PRODUCT> tlist = EASYBUY_PRODUCTDao.selectAllByT(); req.setAttribute("tlist" , tlist); ArrayList<EASYBUY_PRODUCT> hlist = EASYBUY_PRODUCTDao.selectAllByHot(); req.setAttribute("hlist" , hlist); ArrayList<EASYBUY_NEWS> nlist = EASYBUY_NEWSDao.selectAll(); req.setAttribute("nlist" , nlist); 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); } EncodeUtil.encode(req); String dd=req.getParameter("dd" ); ArrayList<EASYBUY_Ddan> dan=EASYBUY_DdanDao.selectById(dd); req.setAttribute("dan" , dan); req.getRequestDispatcher("Dan.jsp" ).forward(req, resp); } } package com.demo.Servlet;public class DoProductUpdateServlet extends HttpServlet { @Override protected void service (HttpServletRequest req, HttpServletResponse resp)
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 43 44 // 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(); 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;
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 public class UserNumServlet extends HttpServlet {@Override protected void service (HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { int width=120 ; int height=60 ; BufferedImage img=new BufferedImage(width, height,BufferedImage.TYPE_INT_RGB); Graphics2D g=img.createGraphics(); g.setColor(Color.LIGHT_GRAY); g.fillRect(0 , 0 , width, height); g.setColor(Color.YELLOW); Random rand=new Random(); for (int i = 0 ; i < 15 ; i++) { int x1=rand.nextInt(width); int y1=rand.nextInt(width); int x2=rand.nextInt(width); int y2=rand.nextInt(width); g.drawLine(x1, y1, x2, y2); } Font f=new Font("Times New Roman" ,Font.BOLD,50 ); g.setFont(f); int red=0 ,green=0 ,blue=0 ; String code="" ; for (int i = 0 ; i < 4 ; i++) { red=rand.nextInt(255 ); 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 );
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 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 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);
——————————PayStart——————————
项目链接: https://javayms.github.io?id=071122582008200ut https://javayms.pages.dev?id=071122582008200ut