基于javaweb+mysql的jsp+servlet停车位预定管理系统(java+jsp+javascript+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的JSP+Servlet停车位预定管理系统(java+jsp+javascript+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版本;
技术栈
HTML+CSS+JavaScript+jsp+mysql
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/login.jsp 登录
yuding.setXingming(rs.getString("xingming"));
yuding.setDianhua(rs.getString("dianhua"));
yuding.setDaodashi(rs.getString("daodashi"));
yuding.setChewei_id(rs.getInt("chewei_id"));
yuding.setUser_id(rs.getString("user_id"));
yuding.setZt(rs.getString("zt"));
yuding.setChewei(liuService.get_chewei(rs.getInt("chewei_id")));
yudingList.add(yuding);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("yudingList", yudingList);
req.getRequestDispatcher("admin/yuding/yudingMana.jsp").forward(req, res);
}
public void yudingShouli(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String id=req.getParameter("id");
String sql="update t_yuding set zt='已受理' where id=?";
Object[] params={id};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("msg", "受理完毕");
String targetURL = "/common/msg.jsp";
dispatch(targetURL, req, res);
}
TZhengce zhengce=new TZhengce();
zhengce.setId(rs.getString("id"));
zhengce.setBiaoti(rs.getString("biaoti"));
zhengce.setNeirong(rs.getString("neirong"));
zhengce.setFujian(rs.getString("fujian"));
zhengce.setShijian(rs.getString("shijian"));
zhengceList.add(zhengce);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("zhengceList", zhengceList);
req.getRequestDispatcher("qiantai/zhengce/zhengceAll.jsp").forward(req, res);
}
public void zhengceDetailQian(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String id=req.getParameter("id");
TZhengce zhengce=new TZhengce();
String sql="select * from t_zhengce where id=?";
Object[] params={id};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
rs.next();
zhengce.setId(rs.getString("id"));
zhengce.setBiaoti(rs.getString("biaoti"));
zhengce.setNeirong(rs.getString("neirong"));
zhengce.setFujian(rs.getString("fujian"));
zhengce.setShijian(rs.getString("shijian"));
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
ting.setId(rs.getInt("id"));
ting.setChewei_id(rs.getInt("chewei_id"));
ting.setChexing(rs.getString("chexing"));
ting.setChepai(rs.getString("chepai"));
ting.setKaishishijian(rs.getString("kaishishijian"));
ting.setJieshushijian(rs.getString("jieshushijian"));
ting.setFeiyong(rs.getInt("feiyong"));
ting.setChewei(liuService.get_chewei(rs.getInt("chewei_id")));
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("ting", ting);
req.getRequestDispatcher("admin/ting/jiesuanPre.jsp").forward(req, res);
}
public void feiyongAdd(HttpServletRequest req,HttpServletResponse res)
{
int chewei_id=Integer.parseInt(req.getParameter("chewei_id"));
int id=Integer.parseInt(req.getParameter("id"));
String jieshushijian=req.getParameter("jieshushijian");
int feiyong=Integer.parseInt(req.getParameter("feiyong"));
String sql="update t_ting set jieshushijian=?,feiyong=? where id=?";
Object[] params={jieshushijian,feiyong,id};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
liuService.update_chewei_zt(chewei_id, "空闲中");
{
}
}
public class loginService
{
public String login(String userName,String userPw,int userType)
{
System.out.println(userType+"UUU");
WebContext ctx = WebContextFactory.get();
HttpSession session=ctx.getSession();
String result="no";
if(userType==0)//系统管理员登陆
{
String sql="select * from t_admin where userName=? and userPw=?";
Object[] params={userName,userPw};
DB mydb=new DB();
mydb.doPstm(sql, params);
try
{
String id=req.getParameter("id");
String sql="update t_user set del='yes' where id=?";
Object[] params={id};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("msg", "用户信息删除完毕");
String targetURL = "/common/msg.jsp";
dispatch(targetURL, req, res);
}
public void userSelect(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
List userList=new ArrayList();
String sql="select * from t_user where del='no'";
Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
Tuser user=new Tuser();
user.setId(rs.getString("id"));
user.setLoginname(rs.getString("loginname"));
user.setLoginpw(rs.getString("loginpw"));
user.setXingming(rs.getString("xingming"));
user.setZhuzhi(rs.getString("zhuzhi"));
user.setDianhua(rs.getString("dianhua"));
user.setDengji(rs.getString("dengji"));
user.setDel(rs.getString("del"));
userList.add(user);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("userList", userList);
req.getRequestDispatcher("admin/yuejuan/userSelect.jsp").forward(req, res);
}
String sql="select * from t_user where del='no'";
Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
Tuser user=new Tuser();
user.setId(rs.getString("id"));
user.setLoginname(rs.getString("loginname"));
user.setLoginpw(rs.getString("loginpw"));
user.setXingming(rs.getString("xingming"));
user.setZhuzhi(rs.getString("zhuzhi"));
user.setDianhua(rs.getString("dianhua"));
user.setDengji(rs.getString("dengji"));
user.setDel(rs.getString("del"));
userList.add(user);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("userList", userList);
req.getRequestDispatcher("admin/user/userMana.jsp").forward(req, res);
}
public void userDel(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String id=req.getParameter("id");
String sql="update t_user set del='yes' where id=?";
Object[] params={id};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("msg", "用户信息删除完毕");
String targetURL = "/common/msg.jsp";
{
userReg(req, res);
}
if(type.endsWith("userEditMe"))
{
userEditMe(req, res);
}
if(type.endsWith("userLogout"))
{
userLogout(req, res);
}
if(type.endsWith("userMana"))
{
userMana(req, res);
}
if(type.endsWith("userDel"))
{
userDel(req, res);
}
if(type.endsWith("userSelect"))
{
userSelect(req, res);
}
}
public void userReg(HttpServletRequest req,HttpServletResponse res)
{
String id=String.valueOf(new Date().getTime());
String loginname=req.getParameter("loginname");
String loginpw=req.getParameter("loginpw");
String xingming=req.getParameter("xingming");
String zhuzhi=req.getParameter("zhuzhi");
String dianhua=req.getParameter("dianhua");
String dengji="普通会员";
String del="no";
String s=liuService.panduan_zhanghao(loginname);
if(s.equals("yizhan"))
{
req.setAttribute("message", "账号已被占用,请输入其他账号");
req.setAttribute("path", "qiantai/userreg/userreg.jsp");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
else
{
String sql="insert into t_user values(?,?,?,?,?,?,?,?)";
Object[] params={id,loginname,loginpw,xingming,zhuzhi,dianhua,dengji,del};
DB mydb=new DB();
mydb.doPstm(sql, params);
public void yudingDel(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String id=req.getParameter("id");
String sql="delete from t_yuding where id=?";
Object[] params={id};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("msg", "信息删除完毕");
String targetURL = "/common/msg.jsp";
dispatch(targetURL, req, res);
}
public void yudingMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
List yudingList=new ArrayList();
String sql="select * from t_yuding order by zt desc";
Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
Tyuding yuding=new Tyuding();
yuding.setId(rs.getString("id"));
yuding.setXingming(rs.getString("xingming"));
yuding.setDianhua(rs.getString("dianhua"));
yuding.setDaodashi(rs.getString("daodashi"));
yuding.setChewei_id(rs.getInt("chewei_id"));
yuding.setUser_id(rs.getString("user_id"));
yuding.setZt(rs.getString("zt"));
yuding.setChewei(liuService.get_chewei(rs.getInt("chewei_id")));
yudingList.add(yuding);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
List cheweiList=new ArrayList();
String sql="select * from t_chewei where del='no' order by quyu";
Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
Tchewei chewei=new Tchewei();
chewei.setId(rs.getInt("id"));
chewei.setBianhao(rs.getString("bianhao"));
chewei.setQuyu(rs.getString("quyu"));
chewei.setZt(rs.getString("zt"));
cheweiList.add(chewei);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("cheweiList", cheweiList);
req.getRequestDispatcher("admin/chewei/cheweiMana.jsp").forward(req, res);
}
public void cheweiSelect(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
List cheweiList=new ArrayList();
String sql="select * from t_chewei where del='no' and zt='空闲中' order by quyu";
Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
Tchewei chewei=new Tchewei();
}
if(type.endsWith("tingMana"))
{
tingMana(req, res);
}
if(type.endsWith("tingDel"))
{
tingDel(req, res);
}
if(type.endsWith("jiesuanPre"))
{
jiesuanPre(req, res);
}
if(type.endsWith("feiyongAdd"))
{
feiyongAdd(req, res);
}
if(type.endsWith("tingRes"))
{
tingRes(req, res);
}
}
public void tingAdd(HttpServletRequest req,HttpServletResponse res)
{
int id=0;
int chewei_id=Integer.parseInt(req.getParameter("chewei_id"));
String chexing=req.getParameter("chexing");
String chepai=req.getParameter("chepai");
String kaishishijian=req.getParameter("kaishishijian");
String jieshushijian="";
int feiyong=0;
String sql="insert into t_ting(chewei_id,chexing,chepai,kaishishijian,jieshushijian,feiyong) values(?,?,?,?,?,?)";
Object[] params={chewei_id,chexing,chepai,kaishishijian,jieshushijian,feiyong};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
liuService.update_chewei_zt(chewei_id, "已占用");
req.setAttribute("msg", "停车信息添加完毕");
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
}
if(userType==2)
{
}
return result;
}
public String userlogin(String userName,String userPw,int userType)
{
WebContext ctx = WebContextFactory.get();
HttpSession session=ctx.getSession();
String result="no";
String sql="select * from t_user where loginname=? and loginpw=? and del='no'";
Object[] params={userName,userPw};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
boolean mark=(rs==null||!rs.next()?false:true);
if(mark==false)
{
result="no";
}
if(mark==true)
{
result="yes";
Tuser user=new Tuser();
user.setId(rs.getString("id"));
user.setLoginname(rs.getString("loginname"));
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
TZhengce zhengce=new TZhengce();
zhengce.setId(rs.getString("id"));
zhengce.setBiaoti(rs.getString("biaoti"));
zhengce.setNeirong(rs.getString("neirong"));
zhengce.setFujian(rs.getString("fujian"));
zhengce.setShijian(rs.getString("shijian"));
zhengceList.add(zhengce);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("zhengceList", zhengceList);
req.getRequestDispatcher("qiantai/zhengce/zhengceAll.jsp").forward(req, res);
}
public void zhengceDetailQian(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String id=req.getParameter("id");
TZhengce zhengce=new TZhengce();
String sql="select * from t_zhengce where id=?";
Object[] params={id};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
rs.next();
HttpSession session=req.getSession();
Tuser user=(Tuser)session.getAttribute("user");
String neirong=req.getParameter("neirong");
String liuyanshi=new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date());
String user_id=user.getId();
String huifu="";
String huifushi="";
String sql="insert into t_liuyan(neirong,liuyanshi,user_id,huifu,huifushi) values(?,?,?,?,?)";
Object[] params={neirong,liuyanshi,user_id,huifu,huifushi};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("msg", "留言完毕");
String targetURL = "/common/msg.jsp";
dispatch(targetURL, req, res);
}
public void liuyanMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
List liuyanList=new ArrayList();
String sql="select * from t_liuyan order by liuyanshi";
Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
TLiuyan liuyan=new TLiuyan();
liuyan.setId(rs.getInt("id"));
liuyan.setNeirong(rs.getString("neirong"));
liuyan.setLiuyanshi(rs.getString("liuyanshi"));
liuyan.setUser_id(rs.getString("user_id"));
liuyan.setHuifu(rs.getString("huifu"));
liuyan.setHuifushi(rs.getString("huifushi"));
liuyanList.add(liuyan);
}
rs.close();
}
catch(Exception e)
{
mydb.closed();
req.setAttribute("cheweiList", cheweiList);
req.getRequestDispatcher("qiantai/chewei/cheweiRes.jsp").forward(req, res);
}
public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
{
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
try
{
dispatch.forward(request, response);
return;
}
catch (ServletException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void destroy()
{
}
}
public class index_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
/*List guanggaoList=liuService.guanggaoList();
if(guanggaoList.size()>3)
{
guanggaoList=guanggaoList.subList(0, 3);
}
req.setAttribute("guanggaoList", guanggaoList);
List xinwenList=liuService.xinwenList();
if(xinwenList.size()>3)
{
xinwenList=xinwenList.subList(0, 3);
}
req.setAttribute("xinwenList", xinwenList);
*/
List zhengceList=liuService.zhengceList();
if(zhengceList.size()>4)
{
zhengceList=zhengceList.subList(0, 4);
}
req.getSession().setAttribute("zhengceList", zhengceList);
List cheweiList=liuService.cheweiList();
req.getSession().setAttribute("cheweiList", cheweiList);
}
}
public class index_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
/*List guanggaoList=liuService.guanggaoList();
if(guanggaoList.size()>3)
{
guanggaoList=guanggaoList.subList(0, 3);
}
req.setAttribute("guanggaoList", guanggaoList);
List xinwenList=liuService.xinwenList();
if(xinwenList.size()>3)
{
xinwenList=xinwenList.subList(0, 3);
}
req.setAttribute("xinwenList", xinwenList);
*/
List zhengceList=liuService.zhengceList();
if(zhengceList.size()>4)
{
zhengceList=zhengceList.subList(0, 4);
}
req.getSession().setAttribute("zhengceList", zhengceList);
List cheweiList=liuService.cheweiList();
req.getSession().setAttribute("cheweiList", cheweiList);
{
zhengceDel(req, res);
}
if(type.endsWith("zhengceDetailHou"))
{
zhengceDetailHou(req, res);
}
if(type.endsWith("zhengceAll"))
{
zhengceAll(req, res);
}
if(type.endsWith("zhengceDetailQian"))
{
zhengceDetailQian(req, res);
}
}
public void zhengceAdd(HttpServletRequest req,HttpServletResponse res)
{
String id=String.valueOf(new Date().getTime());
String biaoti=req.getParameter("biaoti");
String neirong=req.getParameter("neirong");
String fujian=req.getParameter("fujian");
if(fujian.equals(""))
{
fujian="/images/zanwu.jpg";
}
String shijian=new SimpleDateFormat("yyyy-MM-dd").format(new Date());
String sql="insert into t_zhengce values(?,?,?,?,?)";
Object[] params={id,biaoti,neirong,fujian,shijian};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("msg", "操作成功");