首页 前端知识 基于javaweb mysql的jsp servlet酒店管理系统(java jsp bootstrap jquery servlet mysql)

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

2024-01-31 12:01:57 前端知识 前端哥 963 654 我要收藏

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

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

基于javaweb的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
        System.out.print(idcard);
        System.out.print(vip);
        int la = 0;

        if (name == null)
            name = "";
        if (phone == null)
            phone = "";
        boolean isLD = true;

        boolean boo = name.length() > 0 && phone.length() > 0 && isLD;
        String backNews = "";
        try {
            con = DBUtil.getConnection();
            String insertCondition = "INSERT INTO user (name, phone,idcard,vip) VALUES ('" + name + "','" + phone + "','" + idcard + "','" + vip + "')";
            System.out.println(insertCondition);
            sql = con.createStatement();
            if (boo) {
                int m = sql.executeUpdate(insertCondition);
                if (m != 0) {

                    backNews = "注册成功";
                    reg.setBackNews(backNews);
                    reg.setName(name);
                    reg.setPhone(phone);
                    reg.setIdcard(idcard);
                    reg.setVip(vip);
                    reg.setLa(la);
                }
            } else {

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

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

            backNews = "该用户名已使用!";
            reg.setBackNews(backNews);
        }

        RequestDispatcher dispatcher =
                request.getRequestDispatcher("showadduser.jsp");
        dispatcher.forward(request, response);
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request, response);
        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);
    }
                    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);
    }
}

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

        super.init(config);
        try {
            Class.forName(DBUtil.driverClass);
        } catch (Exception e) {
        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;
        Login loginBean = null;
        String backNews = "欢迎进入登陆界面!";
        HttpSession session = request.getSession(true);
        try {
            loginBean = (Login) session.getAttribute("login");
            if (loginBean == null) {
                loginBean = new Login();
                session.setAttribute("login", loginBean);
            }
        } catch (Exception ee) {
            loginBean = new Login();
            session.setAttribute("login", loginBean);
        }
        String aname = request.getParameter("aname").trim(), apwd = request
                .getParameter("apwd").trim(), atype = request.getParameter(
                "atype").trim();
        boolean ok = loginBean.getSuccess();

        System.out.print(aname);
        System.out.print(apwd);
        System.out.print(atype);
        if (ok == true && aname.equals(loginBean.getAname())) {
            backNews = aname + "已经登录了";
            loginBean.setBackNews(backNews);
        } else {
            boolean boo = (aname.length() > 0) && (apwd.length() > 0);
            try {
                con = DBUtil.getConnection();
                String condition = "select * from auser where aname = '"
                        + aname + "' and apwd = '" + apwd + "' and atype = '"
                        + atype + "' ";
                sql = con.createStatement();
                if (boo) {
                    ResultSet rs = sql.executeQuery(condition);
                    boolean m = (rs.next());
        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);
                    reg.setVdiscount(vdiscount);
                    reg.setVdescribe(vdescribe);
                    reg.setVpd(vpd);
                    reg.setLa(la);
                }
            } else {

                backNews = "信息不完整请重试!";
                reg.setBackNews(backNews);
            }
            con.close();
        } catch (SQLException exp) {

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

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

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request, response);
                    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) {
            // TODO: handle exception
        }
    }

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

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

            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(),
                    oday = request.getParameter("oday").trim(), ostate = request.getParameter("ostate").trim();

            String sql2 = "insert into user (name,phone,idcard,vip) values ('" + oname + "','" + ophone + "','" + oidcard + "','0')";
            String sql3 = "update room set rstate='" + request.getParameter("ostate") + "' where rid='" + request.getParameter("roomid") + "'";
            int w = stmt.executeUpdate(sql3);
//            int z = stmt.executeUpdate(sql2);
            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);
        }
    }

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


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

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

public class Handleadduser 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;
        AddUser reg = new AddUser();
        request.setAttribute("register", reg);
        String name = request.getParameter("name").trim(),
                phone = request.getParameter("phone").trim(),
                idcard = request.getParameter("idcard").trim(),
                vip = request.getParameter("vip").trim();
        System.out.print(name);
        System.out.print(phone);
        System.out.print(idcard);
        System.out.print(vip);
        int la = 0;


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 {
            } 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);
    }
}

public class updatevip 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();
            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) {
        }
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        System.out.print(rtdescribe);
        System.out.print(rtmoney);
        int la = 0;

        if (rtypename == null)
            rtypename = "";
        boolean boo = rtypename.length() > 0;
        String backNews = "";
        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);
        if (phone == null)
            phone = "";
        boolean isLD = true;

        boolean boo = name.length() > 0 && phone.length() > 0 && isLD;
        String backNews = "";
        try {
            con = DBUtil.getConnection();
            String insertCondition = "INSERT INTO user (name, phone,idcard,vip) VALUES ('" + name + "','" + phone + "','" + idcard + "','" + vip + "')";
            System.out.println(insertCondition);
            sql = con.createStatement();
            if (boo) {
                int m = sql.executeUpdate(insertCondition);
                if (m != 0) {

                    backNews = "注册成功";
                    reg.setBackNews(backNews);
                    reg.setName(name);
                    reg.setPhone(phone);
                    reg.setIdcard(idcard);
                    reg.setVip(vip);
                    reg.setLa(la);
                }
            } else {

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

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

            backNews = "该用户名已使用!";
            reg.setBackNews(backNews);
        }

        RequestDispatcher dispatcher =
                request.getRequestDispatcher("showadduser.jsp");
        dispatcher.forward(request, response);
    }

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


            Connection con = DBUtil.getConnection();
            Statement stmt = con.createStatement();
            String sql = "update dorder set oid='" + 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(),
                    oday = request.getParameter("oday").trim(), ostate = request.getParameter("ostate").trim();

            String sql2 = "insert into user (name,phone,idcard,vip) values ('" + oname + "','" + ophone + "','" + oidcard + "','0')";
            String sql3 = "update room set rstate='" + request.getParameter("ostate") + "' where rid='" + request.getParameter("roomid") + "'";
            int w = stmt.executeUpdate(sql3);
//            int z = stmt.executeUpdate(sql2);
            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);
        }
    }

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

                out.println("</script>");
            }
        } catch (Exception e) {
            // TODO: handle exception
        }
    }

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

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 {
                    reg.setRtname(rtname);
                    reg.setRstate(rstate);
                    reg.setLa(la);
                }
            } else {

                backNews = "用户信息不完整请重试!";
                reg.setBackNews(backNews);
            }
            con.close();
        } catch (SQLException exp) {

            backNews = "该用户名已使用!";
            reg.setBackNews(backNews);
        }

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

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

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)
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request, response);
    }
}

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)

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

转载请注明出处或者链接地址:https://www.qianduange.cn//article/946.html
标签
mysqlservlet
评论
发布的文章

JQuery中的load()、$

2024-05-10 08:05:15

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!