基于javaweb+mysql的jsp+servlet网上订餐管理系统(java+jsp+bootstrap+jquery+mysql)

基于javaweb+mysql的jsp+servlet网上订餐管理系统(java+jsp+bootstrap+jquery+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

基于javaweb+mysql的JSP+Servlet网上订餐管理系统(java+jsp+bootstrap+jquery+mysql)

项目介绍

基于JSP+Servlet的网上订餐管理系统的设计与实现。该项目为前后台管理项目。 前台主要展示给普通用户,主要功能有菜品分类、最新菜品、销售排行、美食预订、营养小贴士、餐点搜索、订餐车、 在线留言等;

后台主要提供给管理员,主要功能有菜品管理、菜品类别管理、营养小贴士管理、会员管理、员工管理、留言管理、采购管理、销售订单查询、统计管理、用户管理等;

环境需要

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.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 6.数据库:MySql 5.7版本;

技术栈

  1. 后端:Servlet 2. 前端:JSP+bootstrap+jQuery

使用说明

  1. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,下载所需jar包; 2. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 3. 将项目中DBConn.java文件中的数据库配置改为自己的配置 4. 配置tomcat,然后运行项目,输入localhost:8080/xxx 登录 5. 后台管理员账户:admin 密码:admin 前台普通用户:111 密码:111
    {
        if(s == null)
        {
            throw new IllegalArgumentException("File '" + s + "' not found (1040).");
        }
        if(s.equals(""))
        {
            throw new IllegalArgumentException("File '" + s + "' not found (1040).");
        }
        if(!isVirtual(s) && m_denyPhysicalPath)
        {
            throw new SecurityException("Physical path is denied (1035).");
        }
        if(isVirtual(s))
        {
            s = m_application.getRealPath(s);
        }
        java.io.File file = new java.io.File(s);
        FileInputStream fileinputstream = new FileInputStream(file);
        long l = file.length();
        //boolean flag = false;
        int k = 0;
        byte abyte0[] = new byte[i];
        if(s1 == null)
        {
            m_response.setContentType("application/x-msdownload");
        }
        else
        {
            if(s1.length() == 0)
            {
                m_response.setContentType("application/x-msdownload");
            }
            else
            {
                m_response.setContentType(s1);
            }
        }
        m_response.setContentLength((int)l);
        m_contentDisposition = m_contentDisposition != null ? m_contentDisposition : "attachment;";
        if(s2 == null)
        {
            m_response.setHeader("Content-Disposition",m_contentDisposition + " filename=" + getFileName(s));
        }
        else
	}

}

public class RegServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public RegServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		Validate vd = new Validate();
		String name = vd.getUnicode(request.getParameter("name"));
		String pwd = vd.getUnicode(request.getParameter("pwd"));
		String zname = vd.getUnicode(request.getParameter("zname"));
		String sex = vd.getUnicode(request.getParameter("sex"));
		String age = vd.getUnicode(request.getParameter("age"));
		String noid = vd.getUnicode(request.getParameter("noid"));
		String address = vd.getUnicode(request.getParameter("address"));
		String phone = vd.getUnicode(request.getParameter("phone"));
		String email = vd.getUnicode(request.getParameter("email"));
		String code = vd.getUnicode(request.getParameter("code"));
		String sql = "insert into users(name,pwd,realname,sex,age,card,address,phone,email,code) values('"+name+"','"+pwd+"','"+zname+"','"+sex+"','"+age+"','"+noid+"','"+address+"','"+phone+"','"+email+"','"+code+"')";
		InsertUpdateDelBean ib = new InsertUpdateDelBean();
		int flag = ib.insertANDupdateANDdel(sql);
		if(flag == -1){
        //String s1 = new String();
        int i = 0;
        i = s.indexOf("/");
        if(i != -1)
        {
            return s.substring(1,i);
        }
        else
        {
            return s;
        }
    }

    private String getSubTypeMIME(String s)
    {
        //String s1 = new String();
        //boolean flag = false;
        int i = 0;
        i = s.indexOf("/") + 1;
        if(i != -1)
        {
            int j = s.length();
            return s.substring(i,j);
        }
        else
        {
            return s;
        }
    }

    private String getContentDisp(String s)
    {
        //String s1 = new String();
        String s1 = "";
        int i = 0;
        int j = 0;
        i = s.indexOf(":") + 1;
        j = s.indexOf(";");
        s1 = s.substring(i,j);
        return s1;
    }

    private void getDataSection()
    {
        //boolean flag = false;
        //String s = "";
        //String s = new String();
        int i = m_currentIndex;
        int j = 0;
        int k = m_boundary.length();
        out.println("The method of the HTML form must be POST.");
        out.println("</BODY>");
        out.println("</HTML>");
    }

    /**
     * Handles POST requests
     */
    protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
    {

        PrintWriter out = response.getWriter();
        out.println("<HTML>");
        out.println("<BODY BGCOLOR='white'>");
        out.println("<H1>jspSmartUpload : Servlet Sample</H1>");
        out.println("<HR>");

        // Variables
        int count = 0;
        SmartUpload mySmartUpload = new SmartUpload();

        try
        {
            // Initialization
            mySmartUpload.initialize(config,request,response);

            // Upload
            mySmartUpload.upload();

            // Save the file with the original name
            // in a virtual path of the web server
            count = mySmartUpload.save(mySmartUpload.getRequest().getParameter("PATH"));

            // Display the result
            out.println(count + " file uploaded.");

        }
        catch(Exception e)
        {
            out.println("Unable to upload the file.<br>");
            out.println("Error : " + e.toString());
        }

        out.println("</BODY>");
            m_response.setContentType("application/x-msdownload");
        }
        else
        {
            if(s1.length() == 0)
            {
                m_response.setContentType("application/x-msdownload");
            }
            else
            {
                m_response.setContentType(s1);
            }
        }
        m_response.setContentLength((int)l);
        m_contentDisposition = m_contentDisposition != null ? m_contentDisposition : "attachment;";
        if(s2 == null)
        {
            m_response.setHeader("Content-Disposition",m_contentDisposition + " filename=" + getFileName(s));
        }
        else
        {
            if(s2.length() == 0)
            {
                m_response.setHeader("Content-Disposition",m_contentDisposition);
            }
            else
            {
                m_response.setHeader("Content-Disposition",m_contentDisposition + " filename=" + s2);
            }
        }
        while((long)k < l)
        {
            int j = fileinputstream.read(abyte0,0,i);
            k += j;
            m_response.getOutputStream().write(abyte0,0,j);
        }
        fileinputstream.close();
    }

    public void downloadField(ResultSet resultset,String s,String s1,String s2) throws ServletException,IOException,SQLException
    {
        if(resultset == null)
		request.setAttribute("books", al2);
		
		String sql3 = "select * from books order by sums1 desc";
		String[] args3 = {"id","name","author","publishing","number","price","storage","brief","type","tate","sums","imgpath","price1","sums1"};
		ArrayList al3 = ib.select(sql3, args3);
		request.setAttribute("xiaosou", al3);
		
		String sql5 = "select * from books where tate=1";
		String[] args5 = {"id","name","author","publishing","number","price","storage","brief","type","tate","sums","imgpath","price1","sums1"};
		ArrayList al5 = ib.select(sql5, args5);
		request.setAttribute("tuibook", al5);
		
		String sql6 = "select * from books where tate=2";
		String[] args6 = {"id","name","author","publishing","number","price","storage","brief","type","tate","sums","imgpath","price1","sums1"};
		ArrayList al6 = ib.select(sql6, args6);
		request.setAttribute("newbook", al6);
		
		String sql7 = "select * from users";
		String[] args7 = {"id","name","pwd","realname","sex","age","card","address","phone","email","code"};
		ArrayList al7 = ib.select(sql7, args7);
		request.setAttribute("users", al7);
		
		String sql10 = "select * from leaveword";
		String[] args10 = {"id","users","title","content","times"};
		ArrayList al10 = ib.select(sql10, args10);
		request.setAttribute("leaveword", al10);
		
		String sql13 = "select * from books order by id desc";
		String[] args13 = {"id","name","author","publishing","number","price","storage","brief","type","tate","sums","imgpath","price1","sums1"};
		ArrayList al13 = ib.select(sql13, args13);
		request.setAttribute("xiaosou1", al13);
		
		String sql14 = "select * from nutrition";
		String[] args14 = {"id","name","content"};
		ArrayList al14 = ib.select(sql14, args14);
		request.setAttribute("nutrition", al14);
		
		String sql15 = "select * from emp";
		String[] args15 = {"id","name","sex","birthday","phone","addr","duty","estate"};
		ArrayList al15 = ib.select(sql15, args15);
		request.setAttribute("emp", al15);
		
		String sql16 = "select * from stock";
		String[] args16 = {"id","name","unit","sums","price","times"};
		ArrayList al16 = ib.select(sql16, args16);
		request.setAttribute("stock", al16);
		// Put your code here
	}

}

public class ListServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public ListServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		

		SelectBean ib = new SelectBean();
		
		String sql1 = "select * from types";
		String[] args1 = {"id","name"};
		ArrayList al1 = ib.select(sql1, args1);
		request.setAttribute("type", al1);
		
		String sql2 = "select * from books";
		String[] args2 = {"id","name","author","publishing","number","price","storage","brief","type","tate","sums","imgpath","price1","sums1"};
		ArrayList al2 = ib.select(sql2, args2);
		request.setAttribute("books", al2);
        m_response = httpservletresponse;
    }

    public final void initialize(PageContext pagecontext) throws ServletException
    {
        m_application = pagecontext.getServletContext();
        m_request = (HttpServletRequest)pagecontext.getRequest();
        m_response = (HttpServletResponse)pagecontext.getResponse();
    }

    /**
     * @deprecated Method initialize is deprecated
     */
    public final void initialize(ServletContext servletcontext,HttpSession httpsession,HttpServletRequest httpservletrequest,HttpServletResponse httpservletresponse,JspWriter jspwriter) throws ServletException
    {
        m_application = servletcontext;
        m_request = httpservletrequest;
        m_response = httpservletresponse;
    }

    public void upload() throws ServletException,IOException,SmartUploadException
    {
        int i = 0;
        //boolean flag = false;
        boolean flag1 = false;
        //boolean flag2 = false;
        long l = 0L;
        //String s = "";//new String();
        //String s2 = "";//new String();
        String s4 = ""; //new String();
        String s5 = ""; //new String();
        String s6 = ""; //new String();
        String s7 = ""; //new String();
        String s8 = ""; //new String();
        String s9 = ""; //new String();
        String s10 = ""; //new String();
        m_totalBytes = m_request.getContentLength();
        m_binArray = new byte[m_totalBytes];
        int j;
        for(;i < m_totalBytes;i += j)
        {
            try
            {
                m_request.getInputStream();
                j = m_request.getInputStream().read(m_binArray,i,m_totalBytes - i);
            }

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		Validate vd = new Validate();
		String userid = vd.getUnicode(request.getParameter("userid"));
		String bookname = vd.getUnicode(request.getParameter("bookname"));
		String orderda = vd.getUnicode(request.getParameter("orderda"));
		String orderxiao = vd.getUnicode(request.getParameter("orderxiao"));
		String sql = "select a.id as userid,b.id as bookid,c.id as orderid,realname,phone,address,b.name as bookname,booksum,price1,times from users a,books b,orders c where a.id=c.userid and b.id=c.bookid ";
		String[] args = {"userid","bookid","orderid","realname","phone","address","bookname","booksum","price1","times"};
		if(userid != null && !userid.equals("")){
			sql += "and a.id='"+userid+"'";
		}
		if(bookname != null && !bookname.equals("")){
			sql += "and b.name like '%"+bookname+"%'";
		}
		if(orderda != null && !orderda.equals("")){
			sql += "and c.booksum>"+orderda;
		}
		if(orderxiao != null && !orderxiao.equals("")){
			sql += "and c.booksum<"+orderxiao;
		}
		SelectBean sb = new SelectBean();
		ArrayList al = sb.select(sql, args);
		request.setAttribute("order", al);
		RequestDispatcher rd=request.getRequestDispatcher("/admin/order2.jsp");
        rd.forward(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request,response);
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occure
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}


	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		

		SelectBean ib = new SelectBean();
		
		String sql1 = "select * from types";
		String[] args1 = {"id","name"};
		ArrayList al1 = ib.select(sql1, args1);
		request.setAttribute("type", al1);
		
		String sql2 = "select * from books";
		String[] args2 = {"id","name","author","publishing","number","price","storage","brief","type","tate","sums","imgpath","price1","sums1"};
		ArrayList al2 = ib.select(sql2, args2);
		request.setAttribute("books", al2);
		
		String sql3 = "select * from books order by sums1 desc";
		String[] args3 = {"id","name","author","publishing","number","price","storage","brief","type","tate","sums","imgpath","price1","sums1"};
		ArrayList al3 = ib.select(sql3, args3);
		request.setAttribute("xiaosou", al3);
		
		String sql5 = "select * from books where tate=1";
		String[] args5 = {"id","name","author","publishing","number","price","storage","brief","type","tate","sums","imgpath","price1","sums1"};
		ArrayList al5 = ib.select(sql5, args5);
		request.setAttribute("tuibook", al5);
		
		String sql6 = "select * from books where tate=2";
		String[] args6 = {"id","name","author","publishing","number","price","storage","brief","type","tate","sums","imgpath","price1","sums1"};
		ArrayList al6 = ib.select(sql6, args6);
		request.setAttribute("newbook", al6);
		
		String sql7 = "select * from users";
		String[] args7 = {"id","name","pwd","realname","sex","age","card","address","phone","email","code"};
		ArrayList al7 = ib.select(sql7, args7);
		request.setAttribute("users", al7);
		
		String sql10 = "select * from leaveword";
		String[] args10 = {"id","users","title","content","times"};
		ArrayList al10 = ib.select(sql10, args10);
		request.setAttribute("leaveword", al10);
		
		String sql13 = "select * from books order by id desc";
		String[] args13 = {"id","name","author","publishing","number","price","storage","brief","type","tate","sums","imgpath","price1","sums1"};
		ArrayList al13 = ib.select(sql13, args13);
    public void setDeniedFilesList(String s) throws ServletException,IOException,SQLException
    {
        //String s1 = "";
        if(s != null)
        {
            String s2 = "";
            for(int i = 0;i < s.length();i++)
            {
                if(s.charAt(i) == ',')
                {
                    if(!m_deniedFilesList.contains(s2))
                    {
                        m_deniedFilesList.addElement(s2);
                    }
                    s2 = "";
                }
                else
                {
                    s2 = s2 + s.charAt(i);
                }
            }

            //if(s2 != "")
            if(!s2.equals(""))
            {
                m_deniedFilesList.addElement(s2);
            }
        }
        else
        {
            m_deniedFilesList = null;
        }
    }

    public void setAllowedFilesList(String s)
    {
        //String s1 = "";
        if(s != null)
        {
            String s2 = "";
            for(int i = 0;i < s.length();i++)
        byte abyte0[] = new byte[i];
        if(s1 == null)
        {
            m_response.setContentType("application/x-msdownload");
        }
        else
        {
            if(s1.length() == 0)
            {
                m_response.setContentType("application/x-msdownload");
            }
            else
            {
                m_response.setContentType(s1);
            }
        }
        m_response.setContentLength((int)l);
        m_contentDisposition = m_contentDisposition != null ? m_contentDisposition : "attachment;";
        if(s2 == null)
        {
            m_response.setHeader("Content-Disposition",m_contentDisposition + " filename=" + getFileName(s));
        }
        else
        {
            if(s2.length() == 0)
            {
                m_response.setHeader("Content-Disposition",m_contentDisposition);
            }
            else
            {
                m_response.setHeader("Content-Disposition",m_contentDisposition + " filename=" + s2);
            }
        }
        while((long)k < l)
        {
            int j = fileinputstream.read(abyte0,0,i);
            k += j;
            m_response.getOutputStream().write(abyte0,0,j);
        }
        fileinputstream.close();
    }

    public void downloadField(ResultSet resultset,String s,String s1,String s2) throws ServletException,IOException,SQLException
    {
        if(resultset == null)
        {

    public void downloadFile(String s,String s1,String s2) throws ServletException,IOException,SmartUploadException
    {
        downloadFile(s,s1,s2,65000);
    }

    public void downloadFile(String s,String s1,String s2,int i) throws ServletException,IOException,SmartUploadException
    {
        if(s == null)
        {
            throw new IllegalArgumentException("File '" + s + "' not found (1040).");
        }
        if(s.equals(""))
        {
            throw new IllegalArgumentException("File '" + s + "' not found (1040).");
        }
        if(!isVirtual(s) && m_denyPhysicalPath)
        {
            throw new SecurityException("Physical path is denied (1035).");
        }
        if(isVirtual(s))
        {
            s = m_application.getRealPath(s);
        }
        java.io.File file = new java.io.File(s);
        FileInputStream fileinputstream = new FileInputStream(file);
        long l = file.length();
        //boolean flag = false;
        int k = 0;
        byte abyte0[] = new byte[i];
        if(s1 == null)
        {
            m_response.setContentType("application/x-msdownload");
        }
        else
        {
            if(s1.length() == 0)
            {
                m_response.setContentType("application/x-msdownload");
            }
            else
            {
                m_response.setContentType(s1);
            }
        }
        m_response.setContentLength((int)l);
        m_contentDisposition = m_contentDisposition != null ? m_contentDisposition : "attachment;";
        if(s2 == null)
        {
            m_response.setHeader("Content-Disposition",m_contentDisposition + " filename=" + getFileName(s));
        }
			String fileExt = file.getFileExt();
			path="/bookimg";
			
			InsertUpdateDelBean ib = new InsertUpdateDelBean();
			String sql = "insert into books(name,author,brief,type,imgpath,price1)" +
					" values('"+name+"','"+author+"','"+brief+"','"+type+"','"+path.substring(1)+"/"+file.getFileName()+"','"+price1+"')";
			int flag = ib.insertANDupdateANDdel(sql);
			if(flag == -1){
				str = "/admin/addbook.jsp";
				request.setAttribute("error", "1");
			}else{
				str = "/admin/booklist.jsp";
				request.setAttribute("ok", "1");
				count = mySmartUpload.save(path);
			}
		} catch (SmartUploadException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}
		RequestDispatcher rd=request.getRequestDispatcher(str);
        rd.forward(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request,response);
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occure
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}

public class ServletUpload extends HttpServlet
			if(xuser != null && xuser.equals("1")){
				sql = "insert into admin(name,pwd) values('"+name+"','"+pwd+"')";
			}
			int flag = ib.insertANDupdateANDdel(sql);
			if(flag == -1){
				request.setAttribute("error", "1");
				str = "/admin/adduser.jsp";
			}else{
				session.removeAttribute("login");
				str = "/admin/index.jsp";
			}
		}
		RequestDispatcher rd=request.getRequestDispatcher(str);
        rd.forward(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request,response);
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occure
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}

public class LoanBookServlet extends HttpServlet {

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occure
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}

public class DelServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public DelServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		Validate vd = new Validate();
		String bookid = vd.getUnicode(request.getParameter("id"));
		String typeid = vd.getUnicode(request.getParameter("typeid"));
		String sql = "select * from books ";
		String[] args = {"id","name","author","publishing","number","price","storage","brief","type","tate","sums","imgpath","price1","sums1"};
		if(kuda != null && !kuda.equals("")){
			sql += "where storage>"+kuda;
		}
		if(kuxiao != null && !kuxiao.equals("")){
			sql += "where storage<"+kuxiao;
		}
		if(souda != null && !souda.equals("")){
			sql += "where sums>"+souda;
		}
		if(souxiao != null && !souxiao.equals("")){
			sql += "where sums<"+souxiao;
		}
		SelectBean sb = new SelectBean();
		ArrayList al = sb.select(sql, args);
		request.setAttribute("books", al);
		RequestDispatcher rd=request.getRequestDispatcher("/admin/kuxiao.jsp");
        rd.forward(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request,response);
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occure
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}

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

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值