基于javaweb+mysqljsp+servlet酒店管理系统(java+jsp+bootstrap+jquery+servlet+mysql)

私信源码获取调试交流

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

基于javaweb+mysql的JSP+Servlet酒店管理系统(java+jsp+bootstrap+jquery+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项目: 否;查看源码目录是否包含pom.xml;若包含,则为maven项目,否则为非maven项目

技术

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

使用说明

  1. 使用Navicat或者其它工具,在mysql创建对应名称数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令然后运行; 3. 将项目中link/DBUtil.java配置文件中的数据库配置改为自己配置; 4. 运行项目,输入localhost:8080/ 登录 酒店管理员账号/密码admin/admin 操作员账号/密码aa/aa

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;setchar=UTF-8");
        String a = URLEncoder.encode("退房成功!", "UTF-8");
        String b = URLEncoder.encode("退房失败!", "UTF-8");
        int i = 0;
        String bno = request.getParameter("bno");

        try {
            request.setCharacterEncoding("UTF-8");

            Connection con = DBUtil.getConnection();
            Statement stmt = con.createStatement();
            String sql = "update dorder set oid='" + request.getParameter("bno") + "',omoney='" + request.getParameter("omoney") + "',youttime='" + request.getParameter("youttime") + "',yintime='" + request.getParameter("yintime") + "',souttime='" + request.getParameter("souttime") + "',sintime='" + request.getParameter("sintime") + "',oname='" + request.getParameter("oname") + "',ophone='" + request.getParameter("ophone") + "',oidcard='" + request.getParameter("oidcard") + "',ovip='" + request.getParameter("ovip") + "',ostate='" + request.getParameter("ostate") + "',oday='" + request.getParameter("oday") + "',ortname='" + request.getParameter("ortname") + "',roomid='" + request.getParameter("roomid") + "' where oid='" + request.getParameter("bno") + "'";
            System.out.println(sql);
            AddOrder reg = new AddOrder();
            request.setAttribute("register", reg);
            String oname = request.getParameter("oname").trim(), ophone = request.getParameter("ophone").trim(),
                    oidcard = request.getParameter("oidcard").trim(), yintime = request.getParameter("yintime").trim(),
                    ortname = request.getParameter("ortname").trim(), youttime = request.getParameter("youttime").trim(),

            String sql3 = "update room set rstate='" + request.getParameter("ostate") + "' where rid='" + request.getParameter("roomid") + "'";
            int w = stmt.executeUpdate(sql3);
            int q = stmt.executeUpdate(sql);
            if (q == 1) {
                response.setHeader("refresh", "1;url=searchorder.jsp");
            } else {
                response.setHeader("refresh", "1;url=searchorder.jsp");
            }
            stmt.close();
            con.close();

        } catch (Exception e) {
            out.println(e);
        }

        super.init(config);
        try {
            Class.forName(DBUtil.driverClass);
        } catch (Exception e) {
        }
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;setchar=UTF-8");
        String a = URLEncoder.encode("删除成功!", "UTF-8");
        String b = URLEncoder.encode("删除失败!", "UTF-8");
        int i = 0;
        String bno = request.getParameter("bno");

        try {
            if (bno != null) {
                Connection con = DBUtil.getConnection();
                Statement stmt = con.createStatement();

                i = stmt.executeUpdate("delete from user where name='" + bno + "'");
                if (i == 1) {
                    out.println("<script language='javascript'>");
                    out.println("alert(decodeURIComponent('" + a + "') )");
                    out.println("location.href='userlist.jsp'");
                    out.println("</script>");
                } else {
                    out.println("<script language='javascript'>");
                    out.println("alert(decodeURIComponent('" + b + "') )");
                    out.println("location.href='userlist.jsp'");
                    out.println("</script>");
                }
                con.close();
                stmt.close();
            } else {
                out.println("<script language='javascript'>");
                out.println("alert(decodeURIComponent('" + b + "') )");
                out.println("location.href='userlist.jsp'");
                out.println("</script>");
            }

        } catch (Exception e) {
            // TODO: handle exception
        }
    }


public class DelUser extends HttpServlet {
    public void init(ServletConfig config) throws ServletException {

        super.init(config);
        try {
            Class.forName(DBUtil.driverClass);
        } catch (Exception e) {
        }
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;setchar=UTF-8");
        String a = URLEncoder.encode("删除成功!", "UTF-8");
        String b = URLEncoder.encode("删除失败!", "UTF-8");
        int i = 0;
        String bno = request.getParameter("bno");

        try {
            if (bno != null) {
                Connection con = DBUtil.getConnection();
                Statement stmt = con.createStatement();

                i = stmt.executeUpdate("delete from user where name='" + bno + "'");
                if (i == 1) {
                    out.println("<script language='javascript'>");
                    out.println("alert(decodeURIComponent('" + a + "') )");
                    out.println("location.href='userlist.jsp'");
                    out.println("</script>");
                } else {
                    out.println("<script language='javascript'>");
                    out.println("alert(decodeURIComponent('" + b + "') )");
                    out.println("location.href='userlist.jsp'");
                    out.println("</script>");
                }
                con.close();
                stmt.close();
            } else {
                out.println("<script language='javascript'>");
                out.println("alert(decodeURIComponent('" + b + "') )");
                out.println("location.href='userlist.jsp'");
                out.println("</script>");
            }

        } catch (Exception e) {
        try {

            if (bno != null) {

                Connection con = DBUtil.getConnection();
                Statement stmt = con.createStatement();

                i = stmt.executeUpdate("delete from auser where aname='" + bno + "'");
                if (i == 1) {
                    out.println("<script language='javascript'>");
                    out.println("alert(decodeURIComponent('" + a + "') )");
                    out.println("location.href='adminlist.jsp'");
                    out.println("</script>");
                } else {
                    out.println("<script language='javascript'>");
                    out.println("alert(decodeURIComponent('" + b + "') )");
                    out.println("location.href='adminlist.jsp'");
                    out.println("</script>");
                }
                con.close();
                stmt.close();
            } else {
                out.println("<script language='javascript'>");
                out.println("alert(decodeURIComponent('" + b + "') )");
                out.println("location.href='adminlist.jsp'");
                out.println("</script>");
            }
        } catch (Exception e) {
            // TODO: handle exception
        }
    }

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


public class Handleaddroom extends HttpServlet {
    public int t = 0;

    public void init(ServletConfig config) throws ServletException {
        super.init(config);
        try {
            Class.forName(DBUtil.driverClass);
        } catch (Exception e) {
        }
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        Connection con;
        Statement sql;
        AddRoom reg = new AddRoom();
        request.setAttribute("register", reg);
        String rid = request.getParameter("rid").trim(),
                rdescribe = request.getParameter("rdescribe").trim(),
                rtname = request.getParameter("rtname").trim(), rstate = request.getParameter("rstate").trim();
        System.out.print(rid);
        System.out.print(rdescribe);
        System.out.print(rtname);
        System.out.print(rstate);
        int la = 0;

        if (rid == null)
            rid = "";
        if (rstate == null)
            rdescribe = "";
        boolean isLD = true;

        boolean boo = rid.length() > 0 &amp;& rdescribe.length() > 0;
        String backNews = "";
        try {
            con = DBUtil.getConnection();
            String insertCondition = "INSERT INTO room (rid, rdescribe,rstate,rtname) VALUES ('" + rid + "','" + rdescribe + "','" + rstate + "','" + rtname + "')";
            System.out.println(insertCondition);
            sql = con.createStatement();
            if (boo) {
                int m = sql.executeUpdate(insertCondition);
                if (m != 0) {

                    backNews = "添加成功";
                    reg.setBackNews(backNews);
            backNews = "下单失败!";
            reg.setBackNews(backNews);
        }

        RequestDispatcher dispatcher =
                request.getRequestDispatcher("showaddorder2.jsp");//转发
        dispatcher.forward(request, response);
    }

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

public class DelAdmin2 extends HttpServlet {
    public void init(ServletConfig config) throws ServletException {

        super.init(config);
        try {
            Class.forName(DBUtil.driverClass);
        } catch (Exception e) {
        PrintWriter out = response.getWriter();
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;setchar=UTF-8");
        int i = 0;
        String bno = request.getParameter("bno");
        String a = URLEncoder.encode("删除成功!", "UTF-8");
        String b = URLEncoder.encode("删除失败!", "UTF-8");
        try {

            if (bno != null) {

                Connection con = DBUtil.getConnection();
                Statement stmt = con.createStatement();

                i = stmt.executeUpdate("delete from auser where aname='" + bno + "'");
                if (i == 1) {
                    out.println("<script language='javascript'>");
                    out.println("alert(decodeURIComponent('" + a + "') )");
                    out.println("location.href='adminlist.jsp'");
                    out.println("</script>");
                } else {
                    out.println("<script language='javascript'>");
                    out.println("alert(decodeURIComponent('" + b + "') )");
                    out.println("location.href='adminlist.jsp'");
                    out.println("</script>");
                }
                con.close();
                stmt.close();
            } else {
                out.println("<script language='javascript'>");
                out.println("alert(decodeURIComponent('" + b + "') )");
                out.println("location.href='adminlist.jsp'");
                out.println("</script>");
            }
        } catch (Exception e) {
            // TODO: handle exception
        }
    }

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


public class Handleorder extends HttpServlet {
    public int t = 0;

    public void init(ServletConfig config) throws ServletException {
        super.init(config);
        try {
            Class.forName(DBUtil.driverClass);
        } catch (Exception e) {
        }
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        Connection con;
        Statement sql;
        AddOrder reg = new AddOrder();
        request.setAttribute("register", reg);
        String oname = request.getParameter("oname").trim(), ophone = request.getParameter("ophone").trim(),
                oidcard = request.getParameter("oidcard").trim(), yintime = request.getParameter("yintime").trim(),
                ortname = request.getParameter("ortname").trim(), youttime = request.getParameter("youttime").trim(),
        System.out.print(oname);
        System.out.print(oidcard);
        System.out.print(ophone);
        System.out.print(yintime);
        System.out.print(ortname);
        System.out.print(youttime);
        System.out.print(oday);
        System.out.print(ostate);
        int la = 0;

        if (oname == null)
            oname = "";
        boolean boo = oname.length() > 0;
        String backNews = "";
        try {
            con = DBUtil.getConnection();
            String insertCondition = "insert into dorder (oname,ophone,oidcard,yintime,ortname,youttime,oday,ostate) VALUES ('" + oname + "','" + ophone + "','" + oidcard + "','" + yintime + "','" + ortname + "','" + youttime + "','" + oday + "','" + ostate + "')";
            System.out.println(insertCondition);
            sql = con.createStatement();
            if (boo) {
                int m = sql.executeUpdate(insertCondition);
                if (m != 0) {

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

public class DelVip extends HttpServlet {
    public void init(ServletConfig config) throws ServletException {

        super.init(config);
        try {
            Class.forName(DBUtil.driverClass);
        } catch (Exception e) {
        }
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        try {
            con = DBUtil.getConnection();
            String insertCondition = "INSERT INTO roomtype (rtypename,rtdescribe,rtmoney) VALUES ('" + rtypename + "','" + rtdescribe + "','" + rtmoney + "')";
            System.out.println(insertCondition);
            sql = con.createStatement();
            if (boo) {
                int m = sql.executeUpdate(insertCondition);
                if (m != 0) {

                    backNews = "添加成功";
                    reg.setBackNews(backNews);
                    reg.setRtypename(rtypename);
                    reg.setRtdescribe(rtdescribe);
                    reg.setRtmoney(rtmoney);
                    reg.setLa(la);
                }
            } else {

                backNews = "信息完整重试!";
                reg.setBackNews(backNews);

            }
            con.close();
        } catch (SQLException exp) {

            backNews = "该房型已存在!";
            reg.setBackNews(backNews);
        }

        RequestDispatcher dispatcher =
                request.getRequestDispatcher("showaddroomtype.jsp");//转发
        dispatcher.forward(request, response);

    }

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

                        loginBean.setAname(aname);
                        dispatcher = request
                                .getRequestDispatcher("admin/adminMain.jsp");
                    } else if (m == true && atype.equals("1")) {
                        backNews = "第三方管理员登录成功!";
                        loginBean.setBackNews(backNews);
                        loginBean.setSuccess(true);
                        loginBean.setAname(aname);
                        dispatcher = request
                                .getRequestDispatcher("operator/adminMain2.jsp");
                    }
                    else {
                        backNews = "您输入用户名存在,或密码匹配";
                        loginBean.setBackNews(backNews);
                        loginBean.setSuccess(false);
                        loginBean.setAname(aname);
                        loginBean.setApwd(apwd);
                        dispatcher = request
                                .getRequestDispatcher("validatelogon.jsp");
                    }
                } else {
                    backNews = "请输入用户名密码!";
                    loginBean.setBackNews(backNews);
                    loginBean.setSuccess(false);
                    loginBean.setAname(aname);
                    loginBean.setApwd(apwd);
                    dispatcher = request
                            .getRequestDispatcher("validatelogon.jsp");
                }
                con.close();
            } catch (SQLException exp) {
                backNews = "" + exp;
                loginBean.setBackNews(backNews);
                dispatcher = request.getRequestDispatcher("validatelogon.jsp");
            }
        }

        dispatcher.forward(request, response);
    }

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

                response.setHeader("refresh", "1;url=searchorder.jsp");
            }
            stmt.close();
            con.close();

        } catch (Exception e) {
            // TODO: handle exception
        }
    }

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

public class updateorder extends HttpServlet {
    public void init(ServletConfig config) throws ServletException {

        super.init(config);
        try {
            Class.forName(DBUtil.driverClass);
        } catch (Exception e) {
        }
    }

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

public class Handleorder2 extends HttpServlet {
    public int t = 0;

    public void init(ServletConfig config) throws ServletException {
        super.init(config);
        try {
            Class.forName(DBUtil.driverClass);
        } catch (Exception e) {
        }
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        Connection con;
        Statement sql;
        AddOrder reg = new AddOrder();
        request.setAttribute("register", reg);
        String oname = request.getParameter("oname").trim(), ophone = request.getParameter("ophone").trim(),
                oidcard = request.getParameter("oidcard").trim(), yintime = request.getParameter("yintime").trim(),
                ortname = request.getParameter("ortname").trim(), youttime = request.getParameter("youttime").trim(),
        System.out.print(oname);
        System.out.print(oidcard);
        System.out.print(ophone);
        System.out.print(yintime);
        System.out.print(ortname);
        System.out.print(youttime);
        System.out.print(oday);
        System.out.print(ostate);
        int la = 0;

        if (oname == null)
            oname = "";
        boolean boo = oname.length() > 0;
        String backNews = "";
        try {
            con = DBUtil.getConnection();
            String insertCondition = "insert into dorder (oname,ophone,oidcard,yintime,ortname,youttime,oday,ostate) VALUES ('" + oname + "','" + ophone + "','" + oidcard + "','" + yintime + "','" + ortname + "','" + youttime + "','" + oday + "','" + ostate + "')";
            System.out.println(insertCondition);
            sql = con.createStatement();
            if (boo) {
                int m = sql.executeUpdate(insertCondition);
                if (m != 0) {

                    backNews = "添加成功";
                    reg.setBackNews(backNews);
                    reg.setOname(oname);

public class Handleaddvip extends HttpServlet {
    public int t = 0;

    public void init(ServletConfig config) throws ServletException {
        super.init(config);
        try {
            Class.forName(DBUtil.driverClass);
        } catch (Exception e) {
        }
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        Connection con;
        Statement sql;
        AddVip reg = new AddVip();
        request.setAttribute("register", reg);
        String
                vname = request.getParameter("vname").trim(),
                vdiscount = request.getParameter("vdiscount").trim(),
                vdescribe = request.getParameter("vdescribe").trim(),
                vpd = request.getParameter("vpd").trim();
        int la = 0;

        System.out.println(vname);
        System.out.println(vdiscount);
        System.out.println(vdescribe);
        System.out.println(vpd);
        if (vname == null)
            vname = "";
        boolean boo = vname.length() > 0;
        String backNews = "";
        try {
            con = DBUtil.getConnection();
            String insertCondition = "INSERT INTO uservip (vname,vdiscount,vdescribe,vpd) VALUES ('" + vname + "','" + vdiscount + "','" + vdescribe + "','" + vpd + "')";
            System.out.println(insertCondition);
            sql = con.createStatement();
            if (boo) {
                int m = sql.executeUpdate(insertCondition);
                if (m != 0) {

                    backNews = "添加成功";
                    reg.setBackNews(backNews);
                    reg.setVname(vname);
        } catch (Exception e) {
            // TODO: handle exception
        }
    }

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

public class DelUser extends HttpServlet {
    public void init(ServletConfig config) throws ServletException {

        super.init(config);
        try {
            Class.forName(DBUtil.driverClass);
        } catch (Exception e) {
        }
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;setchar=UTF-8");
        String a = URLEncoder.encode("删除成功!", "UTF-8");
        String b = URLEncoder.encode("删除失败!", "UTF-8");
                        backNews = "酒店管理员登录成功!";
                        loginBean.setBackNews(backNews);
                        loginBean.setSuccess(true);
                        loginBean.setAname(aname);
                        dispatcher = request
                                .getRequestDispatcher("admin/adminMain.jsp");
                    } else if (m == true && atype.equals("1")) {
                        backNews = "第三方管理员登录成功!";
                        loginBean.setBackNews(backNews);
                        loginBean.setSuccess(true);
                        loginBean.setAname(aname);
                        dispatcher = request
                                .getRequestDispatcher("operator/adminMain2.jsp");
                    }
                    else {
                        backNews = "您输入的用户名不存在,或密码不匹配";
                        loginBean.setBackNews(backNews);
                        loginBean.setSuccess(false);
                        loginBean.setAname(aname);
                        loginBean.setApwd(apwd);
                        dispatcher = request
                                .getRequestDispatcher("validatelogon.jsp");
                    }
                } else {
                    backNews = "请输入用户名密码!";
                    loginBean.setBackNews(backNews);
                    loginBean.setSuccess(false);
                    loginBean.setAname(aname);
                    loginBean.setApwd(apwd);
                    dispatcher = request
                            .getRequestDispatcher("validatelogon.jsp");
                }
                con.close();
            } catch (SQLException exp) {
                backNews = "" + exp;
                loginBean.setBackNews(backNews);
                dispatcher = request.getRequestDispatcher("validatelogon.jsp");
            }
        }


public class DelRoomType extends HttpServlet {

    public void init(ServletConfig config) throws ServletException {

        super.init(config);
        try {
            Class.forName(DBUtil.driverClass);
        } catch (Exception e) {
        }
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;setchar=UTF-8");
        String a = URLEncoder.encode("删除成功!", "UTF-8");
        String b = URLEncoder.encode("删除失败!", "UTF-8");
        int i = 0;
        String bno = request.getParameter("bno");

        try {

            if (bno != null) {

                Connection con = DBUtil.getConnection();
                Statement stmt = con.createStatement();

                i = stmt.executeUpdate("delete from roomtype where rtid='" + bno + "'");
                if (i == 1) {
                    out.println("<script language='javascript'>");
                    out.println("alert(decodeURIComponent('" + a + "') )");
                    out.println("location.href='roomtypelist.jsp'");
                    out.println("</script>");
                } else {
                    out.println("<script language='javascript'>");
                    out.println("alert(decodeURIComponent('" + b + "') )");
                    out.println("location.href='roomtypelist.jsp'");
                    out.println("</script>");
                }
                con.close();
                stmt.close();
            } else {
                out.println("<script language='javascript'>");

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

原文地址:https://blog.csdn.net/m0_70122726/article/details/134606875

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_33108.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除!

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注