• 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项目:否;

    技术栈

    JSP+CSS+JavaScript+mysql+servlet

    使用说明

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

    管理员账号/密码:admin/admin

    运行截图

    用户角色

     

     

     

     

     

     管理员角色

     

     

     

     

      

    相关代码 

    YudingJiuAction

    1. package com.biyeseng.action;
    2. import java.io.IOException;
    3. import java.io.PrintWriter;
    4. import javax.servlet.ServletException;
    5. import javax.servlet.http.HttpServlet;
    6. import javax.servlet.http.HttpServletRequest;
    7. import javax.servlet.http.HttpServletResponse;
    8. import com.biyeseng.db.DBManager;
    9. import java.sql.*;
    10. import java.util.Date;
    11. /**
    12. * 修改新闻
    13. *
    14. * @author win7
    15. *
    16. */
    17. public class YudingJiuAction extends HttpServlet {
    18. /**
    19. * Constructor of the object.
    20. */
    21. public YudingJiuAction() {
    22. super();
    23. }
    24. /**
    25. * Destruction of the servlet.
    26. */
    27. public void destroy() {
    28. super.destroy(); // Just puts "destroy" string in log
    29. // Put your code here
    30. }
    31. /**
    32. * The doPost method of the servlet.
    33. *
    34. * This method is called when a form has its tag value method equals to
    35. * post.
    36. *
    37. * @param request
    38. * the request send by the client to the server
    39. * @param response
    40. * the response send by the server to the client
    41. * @throws ServletException
    42. * if an error occurred
    43. * @throws IOException
    44. * if an error occurred
    45. */
    46. public void doPost(HttpServletRequest request, HttpServletResponse response)
    47. throws ServletException, IOException {
    48. response.setContentType("text/html");
    49. PrintWriter out = response.getWriter();
    50. String name=request.getParameter("name");
    51. String fang=request.getParameter("fang");
    52. String count=request.getParameter("count");
    53. String bdate=request.getParameter("bdate");
    54. String edate=request.getParameter("edate");
    55. String tel=request.getParameter("tel");
    56. String fangkuan=request.getParameter("fangkuan");
    57. String dingjin=request.getParameter("dingjin");
    58. String ism=request.getParameter("ism");
    59. String mtel=request.getParameter("mtel");
    60. String sql = "insert into yuding(name,fang,count,bdate,edate,tel,fangkuan,dingjin,ism,mtel) values('"+name+"','"+fang+"','"+count+"','"+bdate+"','"+edate+"','"+tel+"','"+fangkuan+"','"+dingjin+"','"+ism+"','"+mtel+"')";
    61. System.out.println(sql);
    62. Statement stat = null;
    63. Connection conn = null;
    64. DBManager dbm = new DBManager();
    65. try {
    66. conn = dbm.getConnection();
    67. stat = conn.createStatement();
    68. stat.execute(sql);
    69. } catch (SQLException e) {
    70. // TODO Auto-generated catch block
    71. e.printStackTrace();
    72. } finally {
    73. try {
    74. if (stat != null)
    75. stat.close();
    76. if (conn != null)
    77. conn.close();
    78. } catch (SQLException e) {
    79. // TODO Auto-generated catch block
    80. e.printStackTrace();
    81. }
    82. }
    83. out
    84. .println("");
    85. out.flush();
    86. out.close();
    87. }
    88. public void doGet(HttpServletRequest request, HttpServletResponse response)
    89. throws ServletException, IOException {
    90. this.doPost(request, response);
    91. }
    92. /**
    93. * Initialization of the servlet.
    94. *
    95. * @throws ServletException
    96. * if an error occurs
    97. */
    98. public void init() throws ServletException {
    99. // Put your code here
    100. }
    101. }

    AddAdminAction

    1. package com.biyeseng.action;
    2. import java.io.IOException;
    3. import java.io.PrintWriter;
    4. import java.sql.*;
    5. import javax.servlet.ServletException;
    6. import javax.servlet.http.HttpServlet;
    7. import javax.servlet.http.HttpServletRequest;
    8. import javax.servlet.http.HttpServletResponse;
    9. import com.biyeseng.db.DBManager;
    10. /**
    11. * 添加管理员
    12. * @author win7
    13. *
    14. */
    15. public class AddAdminAction extends HttpServlet {
    16. /**
    17. * Constructor of the object.
    18. */
    19. public AddAdminAction() {
    20. super();
    21. }
    22. /**
    23. * Destruction of the servlet.
    24. */
    25. public void destroy() {
    26. super.destroy(); // Just puts "destroy" string in log
    27. // Put your code here
    28. }
    29. /**
    30. * The doPost method of the servlet.
    31. *
    32. * This method is called when a form has its tag value method equals to post.
    33. *
    34. * @param request the request send by the client to the server
    35. * @param response the response send by the server to the client
    36. * @throws ServletException if an error occurred
    37. * @throws IOException if an error occurred
    38. */
    39. public void doPost(HttpServletRequest request, HttpServletResponse response)
    40. throws ServletException, IOException {
    41. response.setContentType("text/html");
    42. PrintWriter out = response.getWriter();
    43. String name=request.getParameter("name");
    44. String pwd=request.getParameter("pwd");
    45. String zhi=request.getParameter("zhi");
    46. String tel=request.getParameter("tel");
    47. String age=request.getParameter("age");
    48. DBManager dbm = new DBManager();
    49. //插入管理员信息表
    50. String sql = "insert into admin(userName,userPw,zhi,tel,age) values('"+name+"','"+pwd+"','"+zhi+"','"+tel+"','"+age+"')";
    51. Statement stat = null;
    52. Connection conn=null;
    53. try {
    54. conn=dbm.getConnection();
    55. stat = conn.createStatement();
    56. System.out.println(sql);
    57. stat.execute(sql);
    58. } catch (SQLException e) {
    59. // TODO Auto-generated catch block
    60. e.printStackTrace();
    61. } finally {
    62. try {
    63. if(stat!=null)
    64. stat.close();
    65. if(conn!=null)
    66. conn.close();
    67. } catch (SQLException e) {
    68. // TODO Auto-generated catch block
    69. e.printStackTrace();
    70. }
    71. }
    72. response.sendRedirect("admin/admin/list.jsp");
    73. out.flush();
    74. out.close();
    75. }
    76. /**
    77. * Initialization of the servlet.
    78. *
    79. * @throws ServletException if an error occurs
    80. */
    81. public void init() throws ServletException {
    82. // Put your code here
    83. }
    84. }

    AddJiudianAction

    1. package com.biyeseng.action;
    2. import java.io.File;
    3. import java.io.IOException;
    4. import java.io.PrintWriter;
    5. import java.sql.Connection;
    6. import java.sql.SQLException;
    7. import java.sql.Statement;
    8. import java.util.Date;
    9. import java.util.Iterator;
    10. import java.util.List;
    11. import javax.servlet.ServletException;
    12. import javax.servlet.http.HttpServlet;
    13. import javax.servlet.http.HttpServletRequest;
    14. import javax.servlet.http.HttpServletResponse;
    15. import org.apache.commons.fileupload.DiskFileUpload;
    16. import org.apache.commons.fileupload.FileItem;
    17. import org.apache.commons.fileupload.FileItemFactory;
    18. import org.apache.commons.fileupload.disk.DiskFileItemFactory;
    19. import org.apache.commons.fileupload.servlet.ServletFileUpload;
    20. import com.biyeseng.db.DBManager;
    21. public class AddJiudianAction extends HttpServlet {
    22. /**
    23. * Constructor of the object.
    24. */
    25. public AddJiudianAction() {
    26. super();
    27. }
    28. /**
    29. * Destruction of the servlet.
    30. */
    31. public void destroy() {
    32. super.destroy(); // Just puts "destroy" string in log
    33. // Put your code here
    34. }
    35. /**
    36. * The doGet method of the servlet.
    37. *
    38. * This method is called when a form has its tag value method equals to get.
    39. *
    40. * @param request the request send by the client to the server
    41. * @param response the response send by the server to the client
    42. * @throws ServletException if an error occurred
    43. * @throws IOException if an error occurred
    44. */
    45. public void doGet(HttpServletRequest request, HttpServletResponse response)
    46. throws ServletException, IOException {
    47. this.doPost(request, response);
    48. }
    49. /**
    50. * The doPost method of the servlet.
    51. *
    52. * This method is called when a form has its tag value method equals to post.
    53. *
    54. * @param request the request send by the client to the server
    55. * @param response the response send by the server to the client
    56. * @throws ServletException if an error occurred
    57. * @throws IOException if an error occurred
    58. */
    59. public void doPost(HttpServletRequest request, HttpServletResponse response)
    60. throws ServletException, IOException {
    61. request.setCharacterEncoding("UTF-8");
    62. response.setContentType("text/html");
    63. PrintWriter out = response.getWriter();
    64. DBManager dbm = new DBManager();
    65. String name=request.getParameter("name");
    66. String dizhi=request.getParameter("dizhi");
    67. String info=request.getParameter("info");
    68. String pic=request.getParameter("fujian");
    69. String tel=request.getParameter("tel");
    70. String style=request.getParameter("style");
    71. String date = new Date().toLocaleString();
    72. Object user = request.getSession().getAttribute("user");
    73. String appuser = "";
    74. if (user != null && appuser.toString() != null) {
    75. appuser = (String) user;
    76. }
    77. if(pic != null) {
    78. pic = pic.replaceAll("/upload", "upload");
    79. }
    80. String sql = "insert into jiudian(name,dizhi,info,pic,tel,style) values('"+name+"','"+dizhi+"','"+info+"','"+pic+"','"+tel+"','"+style+"')";
    81. Statement stat = null;
    82. Connection conn = null;
    83. try {
    84. conn = dbm.getConnection();
    85. stat = conn.createStatement();
    86. System.out.println(sql);
    87. stat.execute(sql);
    88. } catch (SQLException e) {
    89. // TODO Auto-generated catch block
    90. e.printStackTrace();
    91. } finally {
    92. try {
    93. if (stat != null)
    94. stat.close();
    95. if (conn != null)
    96. conn.close();
    97. } catch (SQLException e) {
    98. // TODO Auto-generated catch block
    99. e.printStackTrace();
    100. }
    101. }
    102. response.sendRedirect("admin/jiudian/list.jsp");
    103. out.flush();
    104. out.close();
    105. }
    106. /**
    107. * Initialization of the servlet.
    108. *
    109. * @throws ServletException if an error occurs
    110. */
    111. public void init() throws ServletException {
    112. // Put your code here
    113. }
    114. }

    AddKefangAction

    1. package com.biyeseng.action;
    2. import java.io.IOException;
    3. import java.io.PrintWriter;
    4. import java.sql.*;
    5. import javax.servlet.ServletException;
    6. import javax.servlet.http.HttpServlet;
    7. import javax.servlet.http.HttpServletRequest;
    8. import javax.servlet.http.HttpServletResponse;
    9. import com.biyeseng.db.DBManager;
    10. /**
    11. * 添加部门
    12. * @author win7
    13. *
    14. */
    15. public class AddKefangAction extends HttpServlet {
    16. /**
    17. * Constructor of the object.
    18. */
    19. public AddKefangAction() {
    20. super();
    21. }
    22. /**
    23. * Destruction of the servlet.
    24. */
    25. public void destroy() {
    26. super.destroy(); // Just puts "destroy" string in log
    27. // Put your code here
    28. }
    29. /**
    30. * The doPost method of the servlet.
    31. *
    32. * This method is called when a form has its tag value method equals to post.
    33. *
    34. * @param request the request send by the client to the server
    35. * @param response the response send by the server to the client
    36. * @throws ServletException if an error occurred
    37. * @throws IOException if an error occurred
    38. */
    39. public void doPost(HttpServletRequest request, HttpServletResponse response)
    40. throws ServletException, IOException {
    41. response.setContentType("text/html");
    42. PrintWriter out = response.getWriter();
    43. String jid=request.getParameter("jid");
    44. String name=request.getParameter("name");
    45. String chuang=request.getParameter("chuang");
    46. String ren=request.getParameter("ren");
    47. String price=request.getParameter("price");
    48. String type=request.getParameter("type");
    49. String state="";
    50. DBManager dbm = new DBManager();
    51. String sql = "insert into kefang(jid,name,chuang,ren,price,type,state) values("+jid+",'"+name+"','"+chuang+"','"+ren+"','"+price+"','"+type+"','"+state+"')";
    52. System.out.println(sql);
    53. Statement stat = null;
    54. Connection conn=null;
    55. try {
    56. conn=dbm.getConnection();
    57. stat = conn.createStatement();
    58. stat.execute(sql);
    59. } catch (SQLException e) {
    60. // TODO Auto-generated catch block
    61. e.printStackTrace();
    62. } finally {
    63. try {
    64. if(stat!=null)
    65. stat.close();
    66. if(conn!=null)
    67. conn.close();
    68. } catch (SQLException e) {
    69. // TODO Auto-generated catch block
    70. e.printStackTrace();
    71. }
    72. }
    73. response.sendRedirect("admin/kefang/list.jsp?jid="+jid);
    74. out.flush();
    75. out.close();
    76. }
    77. /**
    78. * Initialization of the servlet.
    79. *
    80. * @throws ServletException if an error occurs
    81. */
    82. public void init() throws ServletException {
    83. // Put your code here
    84. }
    85. }

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

  • 相关阅读:
    jQuery网页开发案例:jQuery常用API--jQuery 尺寸、位置操作及 电梯导航案例和节流阀(互斥锁)
    深入理解JVM----垃圾回收算法
    【个人记录】Ceph添加OSD
    小程序自定义组件以及组件传值的简单总结
    物联网开发笔记(17)- 使用Micropython开发ESP32开发板开发环境准备
    继承里的析构函数与构造函数
    基于Echarts的22个可视化大盘静态前台页面
    选择 Guava EventBus 还是 Spring Framework ApplicationEvent
    软件测评的必要性,选择第三方软件测试机构的好处
    Spring框架(四):Spring命名空间和配置标签
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/127037605