作者主页:夜未央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
- package com.servlet;
-
- import java.sql.*;
- import java.io.*;
-
- import javax.servlet.*;
- import javax.servlet.http.*;
-
- import com.bean.AddAdmin;
- import com.link.DBUtil;
-
- public class Handleaddadmin1 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;
- AddAdmin reg = new AddAdmin();
- request.setAttribute("register", reg);
- String aname = request.getParameter("aname").trim(),
- apwd = request.getParameter("apwd").trim(),
- atype = request.getParameter("atype").trim();
- int la = 0;
-
- if (aname == null)
- aname = "";
- if (apwd == null)
- apwd = "";
- boolean isLD = true;
- boolean boo = aname.length() > 0 && apwd.length() > 0 && isLD;
- String backNews = "";
-
- try {
- con = DBUtil.getConnection();
- String insertCondition = "INSERT INTO auser (aname, apwd,atype) VALUES ('" + aname + "','" + apwd + "','" + atype + "')";
-
- sql = con.createStatement();
- if (boo) {
- int m = sql.executeUpdate(insertCondition);
- if (m != 0) {
- backNews = "注册成功";
- reg.setAname(aname);
- reg.setApwd(apwd);
- reg.setAtype(atype);
- reg.setLa(la);
- reg.setBackNews(backNews);
- }
- } else {
- backNews = "用户信息不完整请重试!";
- reg.setBackNews(backNews);
- }
- con.close();
- } catch (SQLException exp) {
-
- backNews = "该用户名已使用!";
- reg.setBackNews(backNews);
- }
-
- RequestDispatcher dispatcher =
- request.getRequestDispatcher("showaddadmin1.jsp");//转发
- dispatcher.forward(request, response);
- }
-
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- doPost(request, response);
- }
- }
- package com.servlet;
-
- import java.io.IOException;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
-
- import javax.servlet.RequestDispatcher;
- import javax.servlet.ServletConfig;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.servlet.http.HttpSession;
-
- import com.bean.Login;
- import com.link.DBUtil;
-
- public class HandleLogin extends HttpServlet {
- private RequestDispatcher dispatcher;
-
- 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;
- 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());
- if (m == true && atype.equals("0")) {
- 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");
- }
- }
-
- dispatcher.forward(request, response);
- }
-
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- doPost(request, response);
- }
- }
- package com.servlet;
-
- import java.sql.*;
- import java.io.*;
- import javax.servlet.*;
- import javax.servlet.http.*;
-
- import com.bean.*;
- import com.link.DBUtil;
-
- 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(),
- oday = request.getParameter("oday").trim(), ostate = request.getParameter("ostate").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);
- reg.setOidcard(oidcard);
- reg.setYintime(yintime);
- reg.setOrtname(ortname);
- reg.setYouttime(youttime);
- reg.setOday(oday);
- reg.setOstate(ostate);
- reg.setLa(la);
- }
- } else {
-
- backNews = "下单失败请重试!";
- reg.setBackNews(backNews);
- }
- con.close();
- } catch (SQLException exp) {
-
- backNews = "下单失败!";
- reg.setBackNews(backNews);
- }
-
- RequestDispatcher dispatcher =
- request.getRequestDispatcher("showaddorder.jsp");//转发
- dispatcher.forward(request, response);
- }
-
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- doPost(request, response);
- }
- }
-
-
- package com.servlet;
-
- import java.sql.*;
- import java.io.*;
- import javax.servlet.*;
- import javax.servlet.http.*;
-
- import com.bean.*;
- import com.link.DBUtil;
-
- 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(),
- oday = request.getParameter("oday").trim(), ostate = request.getParameter("ostate").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);
- reg.setOidcard(oidcard);
- reg.setYintime(yintime);
- reg.setOrtname(ortname);
- reg.setYouttime(youttime);
- reg.setOday(oday);
- reg.setOstate(ostate);
- reg.setLa(la);
- }
- } else {
- backNews = "下单失败请重试!";
- reg.setBackNews(backNews);
- }
- con.close();
- } catch (SQLException exp) {
-
- 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);
- }
- }
-
-
- package com.servlet;
-
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.net.URLEncoder;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.Statement;
-
- import javax.servlet.ServletConfig;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
-
- import com.bean.*;
- import com.link.DBUtil;
-
- public class updatetufang 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 {
- 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(),
- oday = request.getParameter("oday").trim(), ostate = request.getParameter("ostate").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) {
- out.println("");
- response.setHeader("refresh", "1;url=searchorder.jsp");
- } else {
- out.println("");
- 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);
- }
- }
如果也想学习本系统,下面领取。关注并回复:108jsp