Java项目:JSP停车位预定管理系统

127 篇文章 15 订阅
116 篇文章 0 订阅
这是一个JavaWeb项目,包含管理员和用户两种角色,具有登录、信息管理等功能。适合课程设计或毕业设计学习。项目需要JDK1.8、IDEA/Eclipse、Tomcat及MySQL5.7环境,技术栈包括HTML/CSS/JavaScript/jsp/MySQL。管理员和用户有不同的操作页面,登录控制器处理用户和管理员的登录验证。
摘要由CSDN通过智能技术生成

作者主页:夜未央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版本;

技术栈

HTML+CSS+JavaScript+jsp+mysql

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;

2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;

3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;

4. 运行项目,输入localhost:8080/login.jsp 登录

运行截图

用户界面

 

 

 

 

管理端页面

 

 

 

相关代码 

登录控制器

public class LoginAction extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public LoginAction() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 * 
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request
	 *            the request send by the client to the server
	 * @param response
	 *            the response send by the server to the client
	 * @throws ServletException
	 *             if an error occurred
	 * @throws IOException
	 *             if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html;charset=UTF-8");
		PrintWriter out = response.getWriter();
		this.doPost(request, response);
		out.close();
	}

	/**
	 * The doPost method of the servlet. <br>
	 * 
	 * This method is called when a form has its tag value method equals to
	 * post.
	 * 
	 * @param request
	 *            the request send by the client to the server
	 * @param response
	 *            the response send by the server to the client
	 * @throws ServletException
	 *             if an error occurred
	 * @throws IOException
	 *             if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html;charset=UTF-8");
		PrintWriter out = response.getWriter();
		String username = request.getParameter("username");
		String userpwd = request.getParameter("userpwd");
		String type = request.getParameter("type");

		DBManager dbm = new DBManager();

		request.getSession().setAttribute("fei", dbm.getSF());

		if (type.equals("用户")) {
			int uid = dbm.loginYH(username, userpwd);
			if (uid > 0) {
				request.getSession().setAttribute("user", username);
				request.getSession().setAttribute("uid", uid+"");
				request.getSession().setAttribute("type", "用户");
				response.sendRedirect("index.jsp");

			} else {
				out
						.println("<script>alert('用户名或密码有误!');window.location.href='login.jsp'</script>");
			}

		} else if (type.equals("管理员")) {
			boolean login = dbm.login(username, userpwd);
			if (login) {

				request.getSession().setAttribute("user", username);
				request.getSession().setAttribute("type", "管理员");
				response.sendRedirect("index.jsp");

			} else {
				out
						.println("<script>alert('用户名或密码有误!');window.location.href='login.jsp'</script>");
			}
		} else {
			out
					.println("<script>alert('用户名或密码有误!');window.location.href='login.jsp'</script>");
		}

		out.flush();
		out.close();
	}

	/**
	 * Initialization of the servlet. <br>
	 * 
	 * @throws ServletException
	 *             if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}

管理员控制器

public class ModAdminAction extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public ModAdminAction() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html;charset=UTF-8");
		PrintWriter out = response.getWriter();
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		String pwd = request.getParameter("pwd");
	 
		DBManager dbm = new DBManager();
		//修改管理员
		String sql = "update admin set userName='"+name+"',userPw='"+pwd+"' where id="+id;
		System.out.println(sql);

		Statement stat = null;
		Connection conn=null;
		try {
			conn=dbm.getConnection();
			stat = conn.createStatement();
			stat.execute(sql);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {
				if(stat!=null)
					stat.close();
				if(conn!=null)
					conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		response.sendRedirect("admin/list.jsp");
		out.flush();
		out.close();
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

/**	
	 * Constructor of the object.	
	 */	
	public ModCheAction() {	
		super();	
	}	
	
	/**	
	 * Destruction of the servlet. <br>	
	 */	
	public void destroy() {	
		super.destroy(); // Just puts "destroy" string in log	
		// Put your code here	
	}	
	
	/**	
	 * The doPost method of the servlet. <br>	
	 *	
	 * This method is called when a form has its tag value method equals to post.	
	 * 	
	 * @param request the request send by the client to the server	
	 * @param response the response send by the server to the client	
	 * @throws ServletException if an error occurred	
	 * @throws IOException if an error occurred	
	 */	
	public void doPost(HttpServletRequest request, HttpServletResponse response)	
			throws ServletException, IOException {	
	
		response.setContentType("text/html;charset=UTF-8");
		PrintWriter out = response.getWriter();	
		String id = request.getParameter("id");	
		String hao=request.getParameter("hao");
		String leixing=request.getParameter("leixing");
		String pic=request.getParameter("fujian");
		String info=request.getParameter("info");
	 	
		DBManager dbm = new DBManager();	
		//修改车辆
		String sql = "update che set hao='"+hao+"',leixing='"+leixing+"',pic='"+pic+"',info='"+info+"' where id="+id;	
		System.out.println(sql);	
	
		Statement stat = null;	
		Connection conn=null;	
		try {	
			conn=dbm.getConnection();	
			stat = conn.createStatement();	
			stat.execute(sql);	
		} catch (SQLException e) {	
			// TODO Auto-generated catch block	
			e.printStackTrace();	
		} finally {	
			try {	
				if(stat!=null)	
					stat.close();	
				if(conn!=null)	
					conn.close();	
			} catch (SQLException e) {	
				// TODO Auto-generated catch block	
				e.printStackTrace();	
			}	
		}	
		response.sendRedirect("che/list.jsp");	
		out.flush();	
		out.close();	
	}	
	
	/**	
	 * Initialization of the servlet. <br>	
	 *	
	 * @throws ServletException if an error occurs	
	 */	
	public void init() throws ServletException {	
		// Put your code here	
	}	
	

}

车位控制器

public class ModCheweiAction extends HttpServlet {	
	
	/**	
	 * Constructor of the object.	
	 */	
	public ModCheweiAction() {	
		super();	
	}	
	
	/**	
	 * Destruction of the servlet. <br>	
	 */	
	public void destroy() {	
		super.destroy(); // Just puts "destroy" string in log	
		// Put your code here	
	}	
	
	/**	
	 * The doPost method of the servlet. <br>	
	 *	
	 * This method is called when a form has its tag value method equals to post.	
	 * 	
	 * @param request the request send by the client to the server	
	 * @param response the response send by the server to the client	
	 * @throws ServletException if an error occurred	
	 * @throws IOException if an error occurred	
	 */	
	public void doPost(HttpServletRequest request, HttpServletResponse response)	
			throws ServletException, IOException {	
	
		response.setContentType("text/html;charset=UTF-8");
		PrintWriter out = response.getWriter();	
		String id = request.getParameter("id");	
		String hao=request.getParameter("hao");
		String info=request.getParameter("info");
		String qu=request.getParameter("qu");
	 	
		DBManager dbm = new DBManager();	
		//修改车位
		String sql = "update chewei set hao='"+hao+"',info='"+info+"',qu='"+qu+"' where id="+id;	
		System.out.println(sql);	
	
		Statement stat = null;	
		Connection conn=null;	
		try {	
			conn=dbm.getConnection();	
			stat = conn.createStatement();	
			stat.execute(sql);	
		} catch (SQLException e) {	
			// TODO Auto-generated catch block	
			e.printStackTrace();	
		} finally {	
			try {	
				if(stat!=null)	
					stat.close();	
				if(conn!=null)	
					conn.close();	
			} catch (SQLException e) {	
				// TODO Auto-generated catch block	
				e.printStackTrace();	
			}	
		}	
		response.sendRedirect("chewei/list.jsp");	
		out.flush();	
		out.close();	
	}	
	
	/**	
	 * Initialization of the servlet. <br>	
	 *	
	 * @throws ServletException if an error occurs	
	 */	
	public void init() throws ServletException {	
		// Put your code here	
	}	
	
}	

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

初始化停车场(确定停车区个数n,每个停车区的停车位,且初始时,停车场为空),说明:使用一个共享数组(临界资源)存储每个停车区中空闲停车位的个数,每一个停车区使用一个共享缓冲区可容纳一辆车,停车场公共通道允许通过两辆车通过。 停车场入口检查是否有空闲停位,如果有发放相关停车区的停车卡,允许停车。如果不存在空闲车位,等待到有空闲车位止。注,入口处应尽量发放不同停车区的停车卡,以获得更高的效率。停车场过道允许两辆车同时通过。 停车场出口,回收停车卡,并修相关停车区空闲车位数。注:同一时刻只能有一个车出停车场。 每一个停车区,有一个待车位,供进入停车区车辆进入停车区。停车区只能有一辆车进或出。 每辆车每进入下一环节皆应停留一定时间。每一个用户建立一个窗口,于窗口中显示当前将态。将状态转换可由人工确定亦可自动完成,但进入下状态时需要停留学生一定的时间,以保证多个用户“并行”工作。 本框架由四个类组成,这四个类分别是:InitFrame、WotkFram、carJFrame及carThread,由InitFrame启动。类InitFrame提供停车场初始化功能,完成初始任务后启动类WotkFram界面,执行停车场模拟程序,点击命令按扭“进入停车场”,建立一个线程(线程类名为carThread),线程建立一个carJFrame窗口(车辆进入、离开停车场操作程序)模拟车辆进入或离开停车场。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜未央5788

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值