基于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 登录
admin.setUserId(rs.getInt("userId"));
admin.setUserName(rs.getString("userName"));
admin.setUserPw(rs.getString("userPw"));
session.setAttribute("userType", 0);
session.setAttribute("admin", admin);
}
rs.close();
}
catch (SQLException e)
{
System.out.println("登录失败!");
e.printStackTrace();
}
finally
{
mydb.closed();
}
}
if(userType==1)
{
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"));
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"));
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("msg", "修改成功重新登陆后生效");
String targetURL = "/common/msg.jsp";
dispatch(targetURL, req, res);
}
public void userLogout(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
HttpSession session=req.getSession();
session.setAttribute("userType", null);
session.setAttribute("user", null);
req.setAttribute("message", "成功退出系统");
req.setAttribute("path", "qiantai/default.jsp");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void userMana(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"));
String sql="insert into t_yuding values(?,?,?,?,?,?,?)";
Object[] params={id,xingming,dianhua,daodashi,chewei_id,user_id,zt};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("msg", "预订成功");
String targetURL = "/common/msg.jsp";
dispatch(targetURL, req, res);
}
public void yudingMine(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
HttpSession session=req.getSession();
Tuser user=(Tuser)session.getAttribute("user");
List yudingList=new ArrayList();
String sql="select * from t_yuding where user_id=?";
Object[] params={user.getId()};
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();
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("cheweiList", cheweiList);
req.getRequestDispatcher("admin/chewei/cheweiSelect.jsp").forward(req, res);
}
public void cheweiAll(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
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("qiantai/chewei/cheweiRes.jsp").forward(req, res);
}
public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
{
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void destroy()
{
}
}
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=?";
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();
req.setAttribute("zhengce", zhengce);
req.getRequestDispatcher("admin/zhengce/zhengceDetailHou.jsp").forward(req, res);
}
public void zhengceAll(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
List zhengceList=new ArrayList();
String sql="select * from t_zhengce";
Object[] params={};
DB mydb=new DB();
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"));
{
String type=req.getParameter("type");
if(type.endsWith("liuyanAdd"))
{
liuyanAdd(req, res);
}
if(type.endsWith("liuyanMana"))
{
liuyanMana(req, res);
}
if(type.endsWith("liuyanDel"))
{
liuyanDel(req, res);
}
if(type.endsWith("liuyanHuifu"))
{
liuyanHuifu(req, res);
}
if(type.endsWith("liuyanAll"))
{
liuyanAll(req, res);
}
if(type.endsWith("liuyanDetail"))
{
liuyanDetail(req, res);
}
}
public void liuyanAdd(HttpServletRequest req,HttpServletResponse res)
{
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";
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();
}
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";
public class liuyan_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
String type=req.getParameter("type");
if(type.endsWith("liuyanAdd"))
{
liuyanAdd(req, res);
}
if(type.endsWith("liuyanMana"))
{
liuyanMana(req, res);
}
if(type.endsWith("liuyanDel"))
{
liuyanDel(req, res);
}
if(type.endsWith("liuyanHuifu"))
{
liuyanHuifu(req, res);
}
if(type.endsWith("liuyanAll"))
{
liuyanAll(req, res);
}
if(type.endsWith("liuyanDetail"))
{
liuyanDetail(req, res);
{
e.printStackTrace();
}
}
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void destroy()
{
}
}
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";
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
String type=req.getParameter("type");
if(type.endsWith("zhengceAdd"))
{
zhengceAdd(req, res);
}
if(type.endsWith("zhengceMana"))
{
zhengceMana(req, res);
}
if(type.endsWith("zhengceDel"))
{
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(?,?,?,?,?)";
zong=danjia * 1 * beishu;
}
if(fenzhong>60 && fenzhong<120)
{
zong=danjia * 2 * beishu;
}
if(fenzhong>120 && fenzhong<180)
{
zong=danjia * 3 * beishu;
}
if(fenzhong>180 && fenzhong<240)
{
zong=danjia * 4 * beishu;
}
if(fenzhong>240 && fenzhong<300)
{
zong=danjia * 5 * beishu;
}
if(fenzhong>300 && fenzhong<360)
{
zong=danjia * 6 * beishu;
}
if(fenzhong>360 && fenzhong<420)
{
zong=danjia * 7 * beishu;
}
if(fenzhong>420 && fenzhong<480)
{
zong=danjia * 8 * beishu;
}
if(fenzhong>480 && fenzhong<540)
{
zong=danjia * 9 * beishu;
}
if(fenzhong>540 && fenzhong<600)
{
zong=danjia * 10 * beishu;
}
if(fenzhong>600)
{
zong=danjia * 10 * beishu;
}
return zong;
}
}
}
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, "空闲中");
req.setAttribute("msg", "费用结算完毕");
String targetURL = "/common/msg.jsp";
dispatch(targetURL, req, res);
}
public void tingRes(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String chexing=req.getParameter("chexing");
String chepai=req.getParameter("chepai");
List tingList=new ArrayList();
String sql="select * from t_ting where jieshushijian !='' and chexing like '%"+chexing+"%'"+" and chepai like '%"+chepai.trim()+"%'";
Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
Tting ting=new Tting();
ting.setId(rs.getInt("id"));
ting.setChewei_id(rs.getInt("chewei_id"));
ting.setChexing(rs.getString("chexing"));
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)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute("liuyanList", liuyanList);
req.getRequestDispatcher("qiantai/liuyan/liuyanAll.jsp").forward(req, res);
}
public void liuyanDetail(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
int id=Integer.parseInt(req.getParameter("id"));
req.setAttribute("liuyan", get_liuyan(id));
req.getRequestDispatcher("qiantai/liuyan/liuyanDetail.jsp").forward(req, res);
}
public TLiuyan get_liuyan(int id)
{
TLiuyan liuyan=new TLiuyan();
String sql="select * from t_liuyan where id=?";
Object[] params={id};
public class user_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
String type=req.getParameter("type");
if(type.endsWith("userReg"))
{
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="普通会员";
}
if(fenzhong>420 && fenzhong<480)
{
zong=danjia * 8 * beishu;
}
if(fenzhong>480 && fenzhong<540)
{
zong=danjia * 9 * beishu;
}
if(fenzhong>540 && fenzhong<600)
{
zong=danjia * 10 * beishu;
}
if(fenzhong>600)
{
zong=danjia * 10 * beishu;
}
return zong;
}
}
public class yuding_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
zong=danjia * 10 * beishu;
}
if(fenzhong>600)
{
zong=danjia * 10 * beishu;
}
return zong;
}
}
public class yuding_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
String type=req.getParameter("type");
if(type.endsWith("yudingAdd"))