基于javaweb+mysql的jsp+servlet地下停车场管理系统(java+jsp+jquery+servlet+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的JSP+Servlet地下停车场管理系统(java+jsp+jquery+servlet+mysql)
项目介绍
本项目包含管理员与普通用户两种角色;
管理员角色包含以下功能: 管理员登录,添加角色信息,管理角色信息,添加用户信息,管理用户信息,车位信息管理,IC卡信息管理,出入库管理,停车信息管理,临时车辆入库管理,车辆出库管理,修改密码等功能。
用户角色包含以下功能: 用户登录,临时车辆入库管理,车辆出库管理,修改密码,修改个人信息等功能。
环境需要
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项目: 否;
技术栈
- 后端:servlet 2. 前端:JSP+Javascript+css+jQuery
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中db.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/ 用户账号/密码:user/123456 管理员账号/密码:admin/admin
String where = condition + "=\"" + value + "\"";//拼接查询字符串
int page = request.getParameter("page") == null ? 1 : Integer.parseInt(request.getParameter("page"));//获取要跳转的页面号
int wherePage = Integer.parseInt(temp.getPageCountByWhere(where).toString());//获取查询后的分页总数
List<Object> list = temp.getEntityByWhere(where, page);//获取查询后的数据列表
request.setAttribute("list", list);//将数据存放到request对象中,用于转发给前台页面使用
request.setAttribute("wherePage", wherePage);
request.setAttribute("condition", condition);
request.setAttribute("value", value);
request.getRequestDispatcher("/Admin/TempMsg.jsp").forward(request, response);
}
}
package ServletHandle;
public class SeatHandle extends HttpServlet {
HttpServletRequest request;
HttpServletResponse response;
DAL.Seat seat=new DAL.Seat();
//通过表单get方式传值 将进入doGet函数(method="get")
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.response=response;
this.request=request;
int handleType=Integer.parseInt(request.getParameter("type").toString());
switch (handleType) {
case 1://类型1代表删除表中的数据
deleteEntity();
break;
case 4://类型4代表获取表中信息
getEntity();
break;
case 5://类型5代表根据查询条件获取表中信息
getEntityByWhere();
break;
default:
break;
}
{
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
PrintWriter out=response.getWriter();
String UserId=new String(request.getParameter("user_id").getBytes("ISO8859_1"),"UTF-8");
String RoleId=new String(request.getParameter("role_id").getBytes("ISO8859_1"),"UTF-8");
String UserName=new String(request.getParameter("user_name").getBytes("ISO8859_1"),"UTF-8");
String RealName=new String(request.getParameter("real_name").getBytes("ISO8859_1"),"UTF-8");
String UserPwd=new String(request.getParameter("user_pwd1").getBytes("ISO8859_1"),"UTF-8");
String UserPhone=new String(request.getParameter("user_phone").getBytes("ISO8859_1"),"UTF-8");
if(!user.checkExist(UserId))
{
if(user.insertEntity(UserId,RoleId,UserName,RealName,UserPwd,UserPhone)==1)
{
SimpleDateFormat dateFormat =new SimpleDateFormat("yyyyMMddHHmmss");
String AId=dateFormat.format(new Date());
//Account account=new Account();
}
}
else {
}
}
//删除数据操作
private void deleteEntity() throws IOException
{
String user_id=request.getParameter("user_id");//获取前台通过get方式传过来的JId
user.deleteEntity(user_id);//执行删除操作
response.sendRedirect("/Parking/UserHandle?type=4");//删除成功后跳转至管理页面
}
//更新数据操作
private void updateEntity() throws UnsupportedEncodingException
{
String user_id=new String(request.getParameter("user_id").getBytes("ISO8859_1"),"UTF-8");
String role_id=new String(request.getParameter("role_id").getBytes("ISO8859_1"),"UTF-8");
String user_name=new String(request.getParameter("user_name").getBytes("ISO8859_1"),"UTF-8");
String real_name=new String(request.getParameter("real_name").getBytes("ISO8859_1"),"UTF-8");
String user_pwd=new String(request.getParameter("user_pwd").getBytes("ISO8859_1"),"UTF-8");
String user_phone=new String(request.getParameter("user_phone").getBytes("ISO8859_1"),"UTF-8");
if(user.updateEntity(user_id,role_id,user_name,real_name,user_pwd,user_phone)==1)
{
try {
if(request.getSession().getAttribute("role_id").toString().equals("r001"))
{
String role_id=request.getParameter("role_id");//获取前台通过get方式传过来的JId
role.deleteEntity(role_id);//执行删除操作
response.sendRedirect("/Parking/RoleHandle?type=4");//删除成功后跳转至管理页面
}
//更新数据操作
private void updateEntity() throws UnsupportedEncodingException
{
String role_id=new String(request.getParameter("role_id").getBytes("ISO8859_1"),"UTF-8");
String role_name=new String(request.getParameter("role_name").getBytes("ISO8859_1"),"UTF-8");
if(role.updateEntity(role_id,role_name)==1)
{
try {
response.sendRedirect("/Parking/RoleHandle?type=4");//成功更新数据后跳转至RoleMsg.jsp页面
} catch (IOException e) {
e.printStackTrace();//异常处理
}
}
}
//插入数据操作
private void insertEntity() throws UnsupportedEncodingException, IOException
{
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
PrintWriter out=response.getWriter();
String role_id=new String(request.getParameter("role_id").getBytes("ISO8859_1"),"UTF-8");
String role_name=new String(request.getParameter("role_name").getBytes("ISO8859_1"),"UTF-8");
if(!role.checkExist(role_id))
{
if(role.insertEntity(role_id,role_name)==1)
{
}
else {
}
}
else {
}
}
//获取对象所有数据列表
private void getEntity() throws ServletException, IOException
{
request.setCharacterEncoding("UTF-8");
int page=request.getParameter("page")==null?1:Integer.parseInt(request.getParameter("page").toString());//获取跳转的页面号
int totalPage=Integer.parseInt(role.getPageCount().toString()) ;//获取分页总数
else {
}
}
else {
}
}
//获取对象所有数据列表
private void getEntity() throws ServletException, IOException
{
request.setCharacterEncoding("UTF-8");
int page=request.getParameter("page")==null?1:Integer.parseInt(request.getParameter("page").toString());//获取跳转的页面号
int totalPage=Integer.parseInt(user.getPageCount().toString()) ;//获取分页总数
List<Object> list=user.getEntity(page);//获取数据列表
request.setAttribute("list",list);//将数据存放到request对象中,用于转发给前台页面使用
request.setAttribute("totalPage",totalPage );//将totalPage存放到request对象中,用于转发给前台页面使用
request.getRequestDispatcher("/Admin/UserMsg.jsp").forward(request, response);//请求转发
}
//根据查询条件获取对象所有数据列表
private void getEntityByWhere() throws ServletException, IOException
{
request.setCharacterEncoding("UTF-8");
String condition=request.getParameter("condition");//获取查询字段的名称
//String value=new String(request.getParameter("value").getBytes("ISO8859_1"),"UTF-8");//获取查询的值
String value = request.getParameter("value");
String where=condition+"=\""+value+"\"";//拼接查询字符串
int page=request.getParameter("page")==null?1:Integer.parseInt(request.getParameter("page"));//获取要跳转的页面号
int wherePage=Integer.parseInt(user.getPageCountByWhere(where).toString()) ;//获取查询后的分页总数
List<Object> list=user.getEntityByWhere(where, page);//获取查询后的数据列表
request.setAttribute("list",list);//将数据存放到request对象中,用于转发给前台页面使用
request.setAttribute("wherePage",wherePage );
request.setAttribute("condition",condition);
request.setAttribute("value",value);
request.getRequestDispatcher("/Admin/UserMsg.jsp").forward(request, response);
}
}
package ServletHandle;
if(user.insertEntity(UserId,RoleId,UserName,RealName,UserPwd,UserPhone)==1)
{
SimpleDateFormat dateFormat =new SimpleDateFormat("yyyyMMddHHmmss");
String AId=dateFormat.format(new Date());
//Account account=new Account();
}
}
else {
}
}
//删除数据操作
private void deleteEntity() throws IOException
{
String user_id=request.getParameter("user_id");//获取前台通过get方式传过来的JId
user.deleteEntity(user_id);//执行删除操作
response.sendRedirect("/Parking/UserHandle?type=4");//删除成功后跳转至管理页面
}
//更新数据操作
private void updateEntity() throws UnsupportedEncodingException
{
String user_id=new String(request.getParameter("user_id").getBytes("ISO8859_1"),"UTF-8");
String role_id=new String(request.getParameter("role_id").getBytes("ISO8859_1"),"UTF-8");
String user_name=new String(request.getParameter("user_name").getBytes("ISO8859_1"),"UTF-8");
String real_name=new String(request.getParameter("real_name").getBytes("ISO8859_1"),"UTF-8");
String user_pwd=new String(request.getParameter("user_pwd").getBytes("ISO8859_1"),"UTF-8");
String user_phone=new String(request.getParameter("user_phone").getBytes("ISO8859_1"),"UTF-8");
if(user.updateEntity(user_id,role_id,user_name,real_name,user_pwd,user_phone)==1)
{
try {
if(request.getSession().getAttribute("role_id").toString().equals("r001"))
{
response.sendRedirect("/Parking/UserHandle?type=4");//成功更新数据后跳转至UserInfo.jsp页面
}
else {
response.sendRedirect("/Parking/Common/UserInfo.jsp");//成功更新数据后跳转至UserInfo.jsp页面
}
} catch (IOException e) {
e.printStackTrace();//异常处理
}
}
}
//插入数据操作
private void insertEntity() throws UnsupportedEncodingException, IOException
{
getEntityByWhere();
break;
case 6://类型6代表管理员获取未出场车辆
getNoOut();
break;
case 10://类型10代表更新车辆出场
setOut();
break;
default:
break;
}
}
//通过表单post方式传值 将进入doPost函数(method="post")
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.request=request;
this.response=response;
int handleType=Integer.parseInt(request.getParameter("type").toString());//将前台页面传过来的type类型转化成整型
switch (handleType) {
case 2://类型2代表更新表中的数据
updateEntity();
break;
case 3://类型3代表向表中添加数据
insertEntity();
break;
default:
break;
}
}
//删除数据操作
private void deleteEntity() throws IOException
{
String fixed_id=request.getParameter("fixed_id");//获取前台通过get方式传过来的JId
fixed.deleteEntity(fixed_id);//执行删除操作
response.sendRedirect("/Parking/FixedHandle?type=4");//删除成功后跳转至管理页面
}
//车辆出场更新操作
break;
case 3://类型3代表向表中添加数据
insertEntity();
break;
default:
break;
}
}
//删除数据操作
private void deleteEntity() throws IOException
{
String role_id=request.getParameter("role_id");//获取前台通过get方式传过来的JId
role.deleteEntity(role_id);//执行删除操作
response.sendRedirect("/Parking/RoleHandle?type=4");//删除成功后跳转至管理页面
}
//更新数据操作
private void updateEntity() throws UnsupportedEncodingException
{
String role_id=new String(request.getParameter("role_id").getBytes("ISO8859_1"),"UTF-8");
String role_name=new String(request.getParameter("role_name").getBytes("ISO8859_1"),"UTF-8");
if(role.updateEntity(role_id,role_name)==1)
{
try {
response.sendRedirect("/Parking/RoleHandle?type=4");//成功更新数据后跳转至RoleMsg.jsp页面
} catch (IOException e) {
e.printStackTrace();//异常处理
}
}
}
//插入数据操作
private void insertEntity() throws UnsupportedEncodingException, IOException
{
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
PrintWriter out=response.getWriter();
String role_id=new String(request.getParameter("role_id").getBytes("ISO8859_1"),"UTF-8");
String role_name=new String(request.getParameter("role_name").getBytes("ISO8859_1"),"UTF-8");
if(!role.checkExist(role_id))
{
if(role.insertEntity(role_id,role_name)==1)
{
}
else {
}
}
else {
int page=request.getParameter("page")==null?1:Integer.parseInt(request.getParameter("page"));//获取要跳转的页面号
int wherePage=Integer.parseInt(card.getPageCountByWhere(where).toString()) ;//获取查询后的分页总数
List<Object> list=card.getEntityByWhere(where, page);//获取查询后的数据列表
request.setAttribute("list",list);//将数据存放到request对象中,用于转发给前台页面使用
request.setAttribute("wherePage",wherePage );
request.setAttribute("condition",condition);
request.setAttribute("value",value);
request.getRequestDispatcher("/Admin/CardMsg.jsp").forward(request, response);
}
}
package ServletHandle;
public class RoleHandle extends HttpServlet {
HttpServletRequest request;
HttpServletResponse response;
DAL.Role role=new DAL.Role();
//通过表单get方式传值 将进入doGet函数(method="get")
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.response=response;
this.request=request;
int handleType=Integer.parseInt(request.getParameter("type").toString());
switch (handleType) {
case 1://类型1代表删除表中的数据
deleteEntity();
break;
case 4://类型4代表获取表中信息
response.sendRedirect("/Parking/FixedHandle?type=6");
}
}
//更新数据操作
private void updateEntity() throws UnsupportedEncodingException
{
String fixed_id=new String(request.getParameter("fixed_id").getBytes("ISO8859_1"),"UTF-8");
String card_id=new String(request.getParameter("card_id").getBytes("ISO8859_1"),"UTF-8");
String entry_date=new String(request.getParameter("entry_date").getBytes("ISO8859_1"),"UTF-8");
String entry_time=new String(request.getParameter("entry_time").getBytes("ISO8859_1"),"UTF-8");
String out_date=new String(request.getParameter("out_date").getBytes("ISO8859_1"),"UTF-8");
String out_time=new String(request.getParameter("out_time").getBytes("ISO8859_1"),"UTF-8");
if(fixed.updateEntity(fixed_id,card_id,entry_date,entry_time,out_date,out_time)==1)
{
try {
response.sendRedirect("/Parking/FixedHandle?type=4");//成功更新数据后跳转至FixedMsg.jsp页面
} catch (IOException e) {
e.printStackTrace();//异常处理
}
}
}
//插入数据操作
private void insertEntity() throws UnsupportedEncodingException, IOException
{
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
PrintWriter out=response.getWriter();
SimpleDateFormat dateFormat =new SimpleDateFormat("yyyyMMddHHmmss");
String fixed_id=dateFormat.format(new Date());
String card_id=new String(request.getParameter("card_id").getBytes("ISO8859_1"),"UTF-8");
SimpleDateFormat dFormat =new SimpleDateFormat("yyyy-MM-dd");
String entry_date=dFormat.format(new Date());
SimpleDateFormat tFormat =new SimpleDateFormat("HH:mm:ss");
String entry_time=tFormat.format(new Date());
String out_date="1111-11-11";
String out_time="11:11:11";
//System.out.println(card_id);
if(parkList.contains(card_id)) {
return;
}
if((!fixed.checkExist(fixed_id))&&(!card_id.equals(-1)))
{
if(fixed.insertEntity(fixed_id,card_id,entry_date,entry_time,out_date,out_time)==1)
{
parkList.add(card_id);
String AId=dateFormat.format(new Date());
//Account account=new Account();
}
}
else {
}
}
//删除数据操作
private void deleteEntity() throws IOException
{
String user_id=request.getParameter("user_id");//获取前台通过get方式传过来的JId
user.deleteEntity(user_id);//执行删除操作
response.sendRedirect("/Parking/UserHandle?type=4");//删除成功后跳转至管理页面
}
//更新数据操作
private void updateEntity() throws UnsupportedEncodingException
{
String user_id=new String(request.getParameter("user_id").getBytes("ISO8859_1"),"UTF-8");
String role_id=new String(request.getParameter("role_id").getBytes("ISO8859_1"),"UTF-8");
String user_name=new String(request.getParameter("user_name").getBytes("ISO8859_1"),"UTF-8");
String real_name=new String(request.getParameter("real_name").getBytes("ISO8859_1"),"UTF-8");
String user_pwd=new String(request.getParameter("user_pwd").getBytes("ISO8859_1"),"UTF-8");
String user_phone=new String(request.getParameter("user_phone").getBytes("ISO8859_1"),"UTF-8");
if(user.updateEntity(user_id,role_id,user_name,real_name,user_pwd,user_phone)==1)
{
try {
if(request.getSession().getAttribute("role_id").toString().equals("r001"))
{
response.sendRedirect("/Parking/UserHandle?type=4");//成功更新数据后跳转至UserInfo.jsp页面
}
else {
response.sendRedirect("/Parking/Common/UserInfo.jsp");//成功更新数据后跳转至UserInfo.jsp页面
}
} catch (IOException e) {
e.printStackTrace();//异常处理
}
}
}
//插入数据操作
String real_name=new String(request.getParameter("real_name").getBytes("ISO8859_1"),"UTF-8");
String user_pwd=new String(request.getParameter("user_pwd").getBytes("ISO8859_1"),"UTF-8");
String user_phone=new String(request.getParameter("user_phone").getBytes("ISO8859_1"),"UTF-8");
if(!user.checkExist(user_id))
{
if(user.insertEntity(user_id,role_id,user_name,real_name,user_pwd,user_phone)==1)
{
}
else {
}
}
else {
}
}
//获取对象所有数据列表
private void getEntity() throws ServletException, IOException
{
request.setCharacterEncoding("UTF-8");
int page=request.getParameter("page")==null?1:Integer.parseInt(request.getParameter("page").toString());//获取跳转的页面号
int totalPage=Integer.parseInt(user.getPageCount().toString()) ;//获取分页总数
List<Object> list=user.getEntity(page);//获取数据列表
request.setAttribute("list",list);//将数据存放到request对象中,用于转发给前台页面使用
request.setAttribute("totalPage",totalPage );//将totalPage存放到request对象中,用于转发给前台页面使用
request.getRequestDispatcher("/Admin/UserMsg.jsp").forward(request, response);//请求转发
}
//根据查询条件获取对象所有数据列表
private void getEntityByWhere() throws ServletException, IOException
{
request.setCharacterEncoding("UTF-8");
String condition=request.getParameter("condition");//获取查询字段的名称
//String value=new String(request.getParameter("value").getBytes("ISO8859_1"),"UTF-8");//获取查询的值
String value = request.getParameter("value");
String where=condition+"=\""+value+"\"";//拼接查询字符串
int page=request.getParameter("page")==null?1:Integer.parseInt(request.getParameter("page"));//获取要跳转的页面号
int wherePage=Integer.parseInt(user.getPageCountByWhere(where).toString()) ;//获取查询后的分页总数
List<Object> list=user.getEntityByWhere(where, page);//获取查询后的数据列表
request.setAttribute("list",list);//将数据存放到request对象中,用于转发给前台页面使用
request.setAttribute("wherePage",wherePage );
request.setAttribute("condition",condition);
request.setAttribute("value",value);
request.getRequestDispatcher("/Admin/UserMsg.jsp").forward(request, response);
}
}
package ServletHandle;
//插入数据操作
private void insertEntity() throws UnsupportedEncodingException, IOException
{
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
PrintWriter out=response.getWriter();
SimpleDateFormat dateFormat =new SimpleDateFormat("yyyyMMddHHmmss");
String fixed_id=dateFormat.format(new Date());
String card_id=new String(request.getParameter("card_id").getBytes("ISO8859_1"),"UTF-8");
SimpleDateFormat dFormat =new SimpleDateFormat("yyyy-MM-dd");
String entry_date=dFormat.format(new Date());
SimpleDateFormat tFormat =new SimpleDateFormat("HH:mm:ss");
String entry_time=tFormat.format(new Date());
String out_date="1111-11-11";
String out_time="11:11:11";
//System.out.println(card_id);
if(parkList.contains(card_id)) {
return;
}
if((!fixed.checkExist(fixed_id))&&(!card_id.equals(-1)))
{
if(fixed.insertEntity(fixed_id,card_id,entry_date,entry_time,out_date,out_time)==1)
{
parkList.add(card_id);
}
else {
}
}
else {
}
}
//获取对象所有数据列表
private void getEntity() throws ServletException, IOException
this.request=request;
int handleType=Integer.parseInt(request.getParameter("type").toString());
switch (handleType) {
case 1://类型1代表删除表中的数据
deleteEntity();
break;
case 4://类型4代表获取表中信息
getEntity();
break;
case 5://类型5代表根据查询条件获取表中信息
getEntityByWhere();
break;
default:
break;
}
}
//通过表单post方式传值 将进入doPost函数(method="post")
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.request=request;
this.response=response;
int handleType=Integer.parseInt(request.getParameter("type").toString());//将前台页面传过来的type类型转化成整型
switch (handleType) {
case 2://类型2代表更新表中的数据
updateEntity();
break;
case 3://类型3代表向表中添加数据
insertEntity();
break;
case 6://类型6代表向更改密码
chagePwd();
break;
case 7://类型7代表用户更新个人数据
updateEntity();
break;
case 8://用户注册
register();
default:
break;
}
}
//更改密码
private void chagePwd() throws IOException
{
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
PrintWriter out=response.getWriter();
HttpSession session=request.getSession();
String userId=session.getAttribute("user_id").toString();
String oldPwd=new String(request.getParameter("OldPwd").getBytes("ISO8859_1"),"UTF-8");
PrintWriter out=response.getWriter();
SimpleDateFormat dateFormat =new SimpleDateFormat("yyyyMMddHHmmss");
String fixed_id=dateFormat.format(new Date());
String card_id=new String(request.getParameter("card_id").getBytes("ISO8859_1"),"UTF-8");
SimpleDateFormat dFormat =new SimpleDateFormat("yyyy-MM-dd");
String entry_date=dFormat.format(new Date());
SimpleDateFormat tFormat =new SimpleDateFormat("HH:mm:ss");
String entry_time=tFormat.format(new Date());
String out_date="1111-11-11";
String out_time="11:11:11";
//System.out.println(card_id);
if(parkList.contains(card_id)) {
return;
}
if((!fixed.checkExist(fixed_id))&&(!card_id.equals(-1)))
{
if(fixed.insertEntity(fixed_id,card_id,entry_date,entry_time,out_date,out_time)==1)
{
parkList.add(card_id);
}
else {
}
}
else {
}
}
//获取对象所有数据列表
private void getEntity() throws ServletException, IOException
{
request.setCharacterEncoding("UTF-8");
int page=request.getParameter("page")==null?1:Integer.parseInt(request.getParameter("page").toString());//获取跳转的页面号
int totalPage=Integer.parseInt(fixed.getPageCount().toString()) ;//获取分页总数
List<Object> list=fixed.getEntity(page);//获取数据列表
request.setAttribute("list",list);//将数据存放到request对象中,用于转发给前台页面使用
{
String fixed_id=new String(request.getParameter("fixed_id").getBytes("ISO8859_1"),"UTF-8");
String card_id=new String(request.getParameter("card_id").getBytes("ISO8859_1"),"UTF-8");
String entry_date=new String(request.getParameter("entry_date").getBytes("ISO8859_1"),"UTF-8");
String entry_time=new String(request.getParameter("entry_time").getBytes("ISO8859_1"),"UTF-8");
String out_date=new String(request.getParameter("out_date").getBytes("ISO8859_1"),"UTF-8");
String out_time=new String(request.getParameter("out_time").getBytes("ISO8859_1"),"UTF-8");
if(fixed.updateEntity(fixed_id,card_id,entry_date,entry_time,out_date,out_time)==1)
{
try {
response.sendRedirect("/Parking/FixedHandle?type=4");//成功更新数据后跳转至FixedMsg.jsp页面
} catch (IOException e) {
e.printStackTrace();//异常处理
}
}
}
//插入数据操作
private void insertEntity() throws UnsupportedEncodingException, IOException
{
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
PrintWriter out=response.getWriter();
SimpleDateFormat dateFormat =new SimpleDateFormat("yyyyMMddHHmmss");
String fixed_id=dateFormat.format(new Date());
String card_id=new String(request.getParameter("card_id").getBytes("ISO8859_1"),"UTF-8");
SimpleDateFormat dFormat =new SimpleDateFormat("yyyy-MM-dd");
String entry_date=dFormat.format(new Date());
SimpleDateFormat tFormat =new SimpleDateFormat("HH:mm:ss");
String entry_time=tFormat.format(new Date());
String out_date="1111-11-11";
String out_time="11:11:11";
//System.out.println(card_id);
if(parkList.contains(card_id)) {
return;
}
if((!fixed.checkExist(fixed_id))&&(!card_id.equals(-1)))
{
if(fixed.insertEntity(fixed_id,card_id,entry_date,entry_time,out_date,out_time)==1)
{
parkList.add(card_id);
}
else {
}
}
else {
String fixed_id=new String(request.getParameter("fixed_id").getBytes("ISO8859_1"),"UTF-8");
String card_id=new String(request.getParameter("card_id").getBytes("ISO8859_1"),"UTF-8");
String entry_date=new String(request.getParameter("entry_date").getBytes("ISO8859_1"),"UTF-8");
String entry_time=new String(request.getParameter("entry_time").getBytes("ISO8859_1"),"UTF-8");
String out_date=new String(request.getParameter("out_date").getBytes("ISO8859_1"),"UTF-8");
String out_time=new String(request.getParameter("out_time").getBytes("ISO8859_1"),"UTF-8");
if(fixed.updateEntity(fixed_id,card_id,entry_date,entry_time,out_date,out_time)==1)
{
try {
response.sendRedirect("/Parking/FixedHandle?type=4");//成功更新数据后跳转至FixedMsg.jsp页面
} catch (IOException e) {
e.printStackTrace();//异常处理
}
}
}
//插入数据操作
private void insertEntity() throws UnsupportedEncodingException, IOException
{
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
PrintWriter out=response.getWriter();
SimpleDateFormat dateFormat =new SimpleDateFormat("yyyyMMddHHmmss");
String fixed_id=dateFormat.format(new Date());
String card_id=new String(request.getParameter("card_id").getBytes("ISO8859_1"),"UTF-8");
SimpleDateFormat dFormat =new SimpleDateFormat("yyyy-MM-dd");
String entry_date=dFormat.format(new Date());
SimpleDateFormat tFormat =new SimpleDateFormat("HH:mm:ss");
String entry_time=tFormat.format(new Date());
String out_date="1111-11-11";
String out_time="11:11:11";
//System.out.println(card_id);
if(parkList.contains(card_id)) {
return;
}
if((!fixed.checkExist(fixed_id))&&(!card_id.equals(-1)))
{
if(fixed.insertEntity(fixed_id,card_id,entry_date,entry_time,out_date,out_time)==1)
{
parkList.add(card_id);
int page = request.getParameter("page") == null ? 1 : Integer.parseInt(request.getParameter("page").toString());//获取跳转的页面号
int totalPage = Integer.parseInt(temp.getPageCount().toString());//获取分页总数
List<Object> list = temp.getEntity(page);//获取数据列表
request.setAttribute("list", list);//将数据存放到request对象中,用于转发给前台页面使用
request.setAttribute("totalPage", totalPage);//将totalPage存放到request对象中,用于转发给前台页面使用
request.getRequestDispatcher("/Admin/TempMsg.jsp").forward(request, response);//请求转发
}
//根据查询条件获取对象所有数据列表
private void getEntityByWhere() throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
String condition = request.getParameter("condition");//获取查询字段的名称
//String value=new String(request.getParameter("value").getBytes("ISO8859_1"),"UTF-8");//获取查询的值
String value = request.getParameter("value");
String where = condition + "=\"" + value + "\"";//拼接查询字符串
int page = request.getParameter("page") == null ? 1 : Integer.parseInt(request.getParameter("page"));//获取要跳转的页面号
int wherePage = Integer.parseInt(temp.getPageCountByWhere(where).toString());//获取查询后的分页总数
List<Object> list = temp.getEntityByWhere(where, page);//获取查询后的数据列表
request.setAttribute("list", list);//将数据存放到request对象中,用于转发给前台页面使用
request.setAttribute("wherePage", wherePage);
request.setAttribute("condition", condition);
request.setAttribute("value", value);
request.getRequestDispatcher("/Admin/TempMsg.jsp").forward(request, response);
}
}
package ServletHandle;
public class SeatHandle extends HttpServlet {
HttpServletRequest request;
HttpServletResponse response;
DAL.Seat seat=new DAL.Seat();
//通过表单get方式传值 将进入doGet函数(method="get")