• Java项目:JSP酒店管理系统


    作者主页:夜未央5788

     简介:Java领域优质创作者、Java项目、学习资料、技术互助

    文末获取源码

    项目介绍

    该项目主要分为酒店管理员与操作员两种角色;
    酒店管理员角色包含以下功能:
    管理员登录,用户管理、住客信息管理、客房管理、房间管理、会员等级折扣管理、订单管理等功能。

    操作员角色包含以下功能:
    用户登录,用户管理、住客信息管理、房型管理、房间管理、订单管理等功能。

    环境需要

    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

    运行截图

     

     

     

     

     

     

     

     

    相关代码 

    Handleaddadmin1

    1. package com.servlet;
    2. import java.sql.*;
    3. import java.io.*;
    4. import javax.servlet.*;
    5. import javax.servlet.http.*;
    6. import com.bean.AddAdmin;
    7. import com.link.DBUtil;
    8. public class Handleaddadmin1 extends HttpServlet {
    9. public int t = 0;
    10. public void init(ServletConfig config) throws ServletException {
    11. super.init(config);
    12. try {
    13. Class.forName(DBUtil.driverClass);
    14. } catch (Exception e) {
    15. }
    16. }
    17. public void doPost(HttpServletRequest request, HttpServletResponse response)
    18. throws ServletException, IOException {
    19. Connection con;
    20. Statement sql;
    21. AddAdmin reg = new AddAdmin();
    22. request.setAttribute("register", reg);
    23. String aname = request.getParameter("aname").trim(),
    24. apwd = request.getParameter("apwd").trim(),
    25. atype = request.getParameter("atype").trim();
    26. int la = 0;
    27. if (aname == null)
    28. aname = "";
    29. if (apwd == null)
    30. apwd = "";
    31. boolean isLD = true;
    32. boolean boo = aname.length() > 0 && apwd.length() > 0 && isLD;
    33. String backNews = "";
    34. try {
    35. con = DBUtil.getConnection();
    36. String insertCondition = "INSERT INTO auser (aname, apwd,atype) VALUES ('" + aname + "','" + apwd + "','" + atype + "')";
    37. sql = con.createStatement();
    38. if (boo) {
    39. int m = sql.executeUpdate(insertCondition);
    40. if (m != 0) {
    41. backNews = "注册成功";
    42. reg.setAname(aname);
    43. reg.setApwd(apwd);
    44. reg.setAtype(atype);
    45. reg.setLa(la);
    46. reg.setBackNews(backNews);
    47. }
    48. } else {
    49. backNews = "用户信息不完整请重试!";
    50. reg.setBackNews(backNews);
    51. }
    52. con.close();
    53. } catch (SQLException exp) {
    54. backNews = "该用户名已使用!";
    55. reg.setBackNews(backNews);
    56. }
    57. RequestDispatcher dispatcher =
    58. request.getRequestDispatcher("showaddadmin1.jsp");//转发
    59. dispatcher.forward(request, response);
    60. }
    61. public void doGet(HttpServletRequest request, HttpServletResponse response)
    62. throws ServletException, IOException {
    63. doPost(request, response);
    64. }
    65. }

    HandleLogin

    1. package com.servlet;
    2. import java.io.IOException;
    3. import java.sql.Connection;
    4. import java.sql.DriverManager;
    5. import java.sql.ResultSet;
    6. import java.sql.SQLException;
    7. import java.sql.Statement;
    8. import javax.servlet.RequestDispatcher;
    9. import javax.servlet.ServletConfig;
    10. import javax.servlet.ServletException;
    11. import javax.servlet.http.HttpServlet;
    12. import javax.servlet.http.HttpServletRequest;
    13. import javax.servlet.http.HttpServletResponse;
    14. import javax.servlet.http.HttpSession;
    15. import com.bean.Login;
    16. import com.link.DBUtil;
    17. public class HandleLogin extends HttpServlet {
    18. private RequestDispatcher dispatcher;
    19. public void init(ServletConfig config) throws ServletException {
    20. super.init(config);
    21. try {
    22. Class.forName(DBUtil.driverClass);
    23. }
    24. catch (Exception e) {
    25. }
    26. }
    27. public void doPost(HttpServletRequest request, HttpServletResponse response)
    28. throws ServletException, IOException {
    29. Connection con;
    30. Statement sql;
    31. Login loginBean = null;
    32. String backNews = "欢迎进入登陆界面!";
    33. HttpSession session = request.getSession(true);
    34. try {
    35. loginBean = (Login) session.getAttribute("login");
    36. if (loginBean == null) {
    37. loginBean = new Login();
    38. session.setAttribute("login", loginBean);
    39. }
    40. } catch (Exception ee) {
    41. loginBean = new Login();
    42. session.setAttribute("login", loginBean);
    43. }
    44. String aname = request.getParameter("aname").trim(), apwd = request
    45. .getParameter("apwd").trim(), atype = request.getParameter(
    46. "atype").trim();
    47. boolean ok = loginBean.getSuccess();
    48. System.out.print(aname);
    49. System.out.print(apwd);
    50. System.out.print(atype);
    51. if (ok == true && aname.equals(loginBean.getAname())) {
    52. backNews = aname + "已经登录了";
    53. loginBean.setBackNews(backNews);
    54. } else {
    55. boolean boo = (aname.length() > 0) && (apwd.length() > 0);
    56. try {
    57. con = DBUtil.getConnection();
    58. String condition = "select * from auser where aname = '"
    59. + aname + "' and apwd = '" + apwd + "' and atype = '"
    60. + atype + "' ";
    61. sql = con.createStatement();
    62. if (boo) {
    63. ResultSet rs = sql.executeQuery(condition);
    64. boolean m = (rs.next());
    65. if (m == true && atype.equals("0")) {
    66. backNews = "酒店管理员登录成功!";
    67. loginBean.setBackNews(backNews);
    68. loginBean.setSuccess(true);
    69. loginBean.setAname(aname);
    70. dispatcher = request
    71. .getRequestDispatcher("admin/adminMain.jsp");
    72. } else if (m == true && atype.equals("1")) {
    73. backNews = "第三方管理员登录成功!";
    74. loginBean.setBackNews(backNews);
    75. loginBean.setSuccess(true);
    76. loginBean.setAname(aname);
    77. dispatcher = request
    78. .getRequestDispatcher("operator/adminMain2.jsp");
    79. }
    80. else {
    81. backNews = "您输入的用户名不存在,或密码不匹配";
    82. loginBean.setBackNews(backNews);
    83. loginBean.setSuccess(false);
    84. loginBean.setAname(aname);
    85. loginBean.setApwd(apwd);
    86. dispatcher = request
    87. .getRequestDispatcher("validatelogon.jsp");
    88. }
    89. } else {
    90. backNews = "请输入用户名密码!";
    91. loginBean.setBackNews(backNews);
    92. loginBean.setSuccess(false);
    93. loginBean.setAname(aname);
    94. loginBean.setApwd(apwd);
    95. dispatcher = request
    96. .getRequestDispatcher("validatelogon.jsp");
    97. }
    98. con.close();
    99. } catch (SQLException exp) {
    100. backNews = "" + exp;
    101. loginBean.setBackNews(backNews);
    102. dispatcher = request.getRequestDispatcher("validatelogon.jsp");
    103. }
    104. }
    105. dispatcher.forward(request, response);
    106. }
    107. public void doGet(HttpServletRequest request, HttpServletResponse response)
    108. throws ServletException, IOException {
    109. doPost(request, response);
    110. }
    111. }

    Handleorder

    1. package com.servlet;
    2. import java.sql.*;
    3. import java.io.*;
    4. import javax.servlet.*;
    5. import javax.servlet.http.*;
    6. import com.bean.*;
    7. import com.link.DBUtil;
    8. public class Handleorder extends HttpServlet {
    9. public int t = 0;
    10. public void init(ServletConfig config) throws ServletException {
    11. super.init(config);
    12. try {
    13. Class.forName(DBUtil.driverClass);
    14. } catch (Exception e) {
    15. }
    16. }
    17. public void doPost(HttpServletRequest request, HttpServletResponse response)
    18. throws ServletException, IOException {
    19. Connection con;
    20. Statement sql;
    21. AddOrder reg = new AddOrder();
    22. request.setAttribute("register", reg);
    23. String oname = request.getParameter("oname").trim(), ophone = request.getParameter("ophone").trim(),
    24. oidcard = request.getParameter("oidcard").trim(), yintime = request.getParameter("yintime").trim(),
    25. ortname = request.getParameter("ortname").trim(), youttime = request.getParameter("youttime").trim(),
    26. oday = request.getParameter("oday").trim(), ostate = request.getParameter("ostate").trim();//����
    27. System.out.print(oname);
    28. System.out.print(oidcard);
    29. System.out.print(ophone);
    30. System.out.print(yintime);
    31. System.out.print(ortname);
    32. System.out.print(youttime);
    33. System.out.print(oday);
    34. System.out.print(ostate);
    35. int la = 0;
    36. if (oname == null)
    37. oname = "";
    38. boolean boo = oname.length() > 0;
    39. String backNews = "";
    40. try {
    41. con = DBUtil.getConnection();
    42. String insertCondition = "insert into dorder (oname,ophone,oidcard,yintime,ortname,youttime,oday,ostate) VALUES ('" + oname + "','" + ophone + "','" + oidcard + "','" + yintime + "','" + ortname + "','" + youttime + "','" + oday + "','" + ostate + "')";
    43. System.out.println(insertCondition);
    44. sql = con.createStatement();
    45. if (boo) {
    46. int m = sql.executeUpdate(insertCondition);
    47. if (m != 0) {
    48. backNews = "添加成功";
    49. reg.setBackNews(backNews);
    50. reg.setOname(oname);
    51. reg.setOidcard(oidcard);
    52. reg.setYintime(yintime);
    53. reg.setOrtname(ortname);
    54. reg.setYouttime(youttime);
    55. reg.setOday(oday);
    56. reg.setOstate(ostate);
    57. reg.setLa(la);
    58. }
    59. } else {
    60. backNews = "下单失败请重试!";
    61. reg.setBackNews(backNews);
    62. }
    63. con.close();
    64. } catch (SQLException exp) {
    65. backNews = "下单失败!";
    66. reg.setBackNews(backNews);
    67. }
    68. RequestDispatcher dispatcher =
    69. request.getRequestDispatcher("showaddorder.jsp");//转发
    70. dispatcher.forward(request, response);
    71. }
    72. public void doGet(HttpServletRequest request, HttpServletResponse response)
    73. throws ServletException, IOException {
    74. doPost(request, response);
    75. }
    76. }

    Handleorder2

    1. package com.servlet;
    2. import java.sql.*;
    3. import java.io.*;
    4. import javax.servlet.*;
    5. import javax.servlet.http.*;
    6. import com.bean.*;
    7. import com.link.DBUtil;
    8. public class Handleorder2 extends HttpServlet {
    9. public int t = 0;
    10. public void init(ServletConfig config) throws ServletException {
    11. super.init(config);
    12. try {
    13. Class.forName(DBUtil.driverClass);
    14. } catch (Exception e) {
    15. }
    16. }
    17. public void doPost(HttpServletRequest request, HttpServletResponse response)
    18. throws ServletException, IOException {
    19. Connection con;
    20. Statement sql;
    21. AddOrder reg = new AddOrder();
    22. request.setAttribute("register", reg);
    23. String oname = request.getParameter("oname").trim(), ophone = request.getParameter("ophone").trim(),
    24. oidcard = request.getParameter("oidcard").trim(), yintime = request.getParameter("yintime").trim(),
    25. ortname = request.getParameter("ortname").trim(), youttime = request.getParameter("youttime").trim(),
    26. oday = request.getParameter("oday").trim(), ostate = request.getParameter("ostate").trim();//����
    27. System.out.print(oname);
    28. System.out.print(oidcard);
    29. System.out.print(ophone);
    30. System.out.print(yintime);
    31. System.out.print(ortname);
    32. System.out.print(youttime);
    33. System.out.print(oday);
    34. System.out.print(ostate);
    35. int la = 0;
    36. if (oname == null)
    37. oname = "";
    38. boolean boo = oname.length() > 0;
    39. String backNews = "";
    40. try {
    41. con = DBUtil.getConnection();
    42. String insertCondition = "insert into dorder (oname,ophone,oidcard,yintime,ortname,youttime,oday,ostate) VALUES ('" + oname + "','" + ophone + "','" + oidcard + "','" + yintime + "','" + ortname + "','" + youttime + "','" + oday + "','" + ostate + "')";
    43. System.out.println(insertCondition);
    44. sql = con.createStatement();
    45. if (boo) {
    46. int m = sql.executeUpdate(insertCondition);
    47. if (m != 0) {
    48. backNews = "添加成功";
    49. reg.setBackNews(backNews);
    50. reg.setOname(oname);
    51. reg.setOidcard(oidcard);
    52. reg.setYintime(yintime);
    53. reg.setOrtname(ortname);
    54. reg.setYouttime(youttime);
    55. reg.setOday(oday);
    56. reg.setOstate(ostate);
    57. reg.setLa(la);
    58. }
    59. } else {
    60. backNews = "下单失败请重试!";
    61. reg.setBackNews(backNews);
    62. }
    63. con.close();
    64. } catch (SQLException exp) {
    65. backNews = "下单失败!";
    66. reg.setBackNews(backNews);
    67. }
    68. RequestDispatcher dispatcher =
    69. request.getRequestDispatcher("showaddorder2.jsp");//转发
    70. dispatcher.forward(request, response);
    71. }
    72. public void doGet(HttpServletRequest request, HttpServletResponse response)
    73. throws ServletException, IOException {
    74. doPost(request, response);
    75. }
    76. }

    updatetufang

    1. package com.servlet;
    2. import java.io.IOException;
    3. import java.io.PrintWriter;
    4. import java.net.URLEncoder;
    5. import java.sql.Connection;
    6. import java.sql.DriverManager;
    7. import java.sql.Statement;
    8. import javax.servlet.ServletConfig;
    9. import javax.servlet.ServletException;
    10. import javax.servlet.http.HttpServlet;
    11. import javax.servlet.http.HttpServletRequest;
    12. import javax.servlet.http.HttpServletResponse;
    13. import com.bean.*;
    14. import com.link.DBUtil;
    15. public class updatetufang extends HttpServlet {
    16. public void init(ServletConfig config) throws ServletException {
    17. super.init(config);
    18. try {
    19. Class.forName(DBUtil.driverClass);
    20. } catch (Exception e) {
    21. }
    22. }
    23. public void doPost(HttpServletRequest request, HttpServletResponse response)
    24. throws ServletException, IOException {
    25. PrintWriter out = response.getWriter();
    26. request.setCharacterEncoding("UTF-8");
    27. response.setCharacterEncoding("UTF-8");
    28. response.setContentType("text/html;setchar=UTF-8");
    29. String a = URLEncoder.encode("退房成功!", "UTF-8");
    30. String b = URLEncoder.encode("退房失败!", "UTF-8");
    31. int i = 0;
    32. String bno = request.getParameter("bno");
    33. try {
    34. request.setCharacterEncoding("UTF-8");
    35. Connection con = DBUtil.getConnection();
    36. Statement stmt = con.createStatement();
    37. 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") + "'";
    38. System.out.println(sql);
    39. AddOrder reg = new AddOrder();
    40. request.setAttribute("register", reg);
    41. String oname = request.getParameter("oname").trim(), ophone = request.getParameter("ophone").trim(),
    42. oidcard = request.getParameter("oidcard").trim(), yintime = request.getParameter("yintime").trim(),
    43. ortname = request.getParameter("ortname").trim(), youttime = request.getParameter("youttime").trim(),
    44. oday = request.getParameter("oday").trim(), ostate = request.getParameter("ostate").trim();//����
    45. String sql3 = "update room set rstate='" + request.getParameter("ostate") + "' where rid='" + request.getParameter("roomid") + "'";
    46. int w = stmt.executeUpdate(sql3);
    47. int q = stmt.executeUpdate(sql);
    48. if (q == 1) {
    49. out.println("");
    50. response.setHeader("refresh", "1;url=searchorder.jsp");
    51. } else {
    52. out.println("");
    53. response.setHeader("refresh", "1;url=searchorder.jsp");
    54. }
    55. stmt.close();
    56. con.close();
    57. } catch (Exception e) {
    58. out.println(e);
    59. }
    60. }
    61. public void doGet(HttpServletRequest request, HttpServletResponse response)
    62. throws ServletException, IOException {
    63. doPost(request, response);
    64. }
    65. }

    如果也想学习本系统,下面领取。关注并回复:108jsp

  • 相关阅读:
    【c++每天一题】 字符串压缩
    算法 数据结构 斐波那契数列 递归实现斐波那契数列 斐波那契递归的优化 斐波那契数列递归求解 多路递归实现 斐波那契算法系列 数据结构(十一)
    Flink中Table API和SQL(一)
    linux网络编程之socket,bind,listen,connect,accept
    数组专题总结
    pycharm更改远程服务器地址
    CMakeLists中Set编译器要放在project设定之前
    用DIV+CSS技术设计的公益主题网站——防止电信诈骗(web前端网页制作课作业)
    POJ 3481、HDU 1908、AcWing 5125:双端队列 ← STL map
    Cmake小总结
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/126917112