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;
default:
break;
}
}
//删除数据操作
private void deleteEntity() throws IOException {
String card_id = request.getParameter(“card_id”);//获取前台通过get方式传过来的JId
card.deleteEntity(card_id);//执行删除操作
response.sendRedirect(“/Parking/CardHandle?type=4”);//删除成功后跳转至管理页面
}
//更新数据操作
private void updateEntity() throws UnsupportedEncodingException {
String card_id = new String(request.getParameter(“card_id”).getBytes(“ISO8859_1”), “UTF-8”);
String seat_id = new String(request.getParameter(“seat_id”).getBytes(“ISO8859_1”), “UTF-8”);
String user_name = new String(request.getParameter(“user_name”).getBytes(“ISO8859_1”), “UTF-8”);
String user_gender = new String(request.getParameter(“user_gender”).getBytes(“ISO8859_1”), “UTF-8”);
String user_addr = new String(request.getParameter(“user_addr”).getBytes(“ISO8859_1”), “UTF-8”);
String car_num = new String(request.getParameter(“car_num”).getBytes(“ISO8859_1”), “UTF-8”);
if (card.updateEntity(card_id, seat_id, user_name, user_gender, user_addr, car_num) == 1) {
try {
response.sendRedirect(“/Parking/CardHandle?type=4”);//成功更新数据后跳转至CardMsg.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 card_id = dateFormat.format(new Date());
String seat_id = new String(request.getParameter(“seat_id”).getBytes(“ISO8859_1”), “UTF-8”);
String user_name = new String(request.getParameter(“user_name”).getBytes(“ISO8859_1”), “UTF-8”);
String user_gender = new String(request.getParameter(“user_gender”).getBytes(“ISO8859_1”), “UTF-8”);
String user_addr = new String(request.getParameter(“user_addr”).getBytes(“ISO8859_1”), “UTF-8”);
String car_num = new String(request.getParameter(“car_num”).getBytes(“ISO8859_1”), “UTF-8”);
if (!card.checkExist(card_id)) {
if (card.insertEntity(card_id, seat_id, user_name, user_gender, user_addr, car_num) == 1) {
out.write(“”);
} else {
out.write(“”);
}
} else {
out.write(“”);
}
}
//获取对象所有数据列表
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(card.getPageCount().toString());//获取分页总数
List list = card.getEntity(page);//获取数据列表
request.setAttribute(“list”, list);//将数据存放到request对象中,用于转发给前台页面使用
request.setAttribute(“totalPage”, totalPage);//将totalPage存放到request对象中,用于转发给前台页面使用
request.getRequestDispatcher(“/Admin/CardMsg.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(card.getPageCountByWhere(where).toString());//获取查询后的分页总数
List 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);
}
}
FixedHandle
package ServletHandle;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.*;
public class FixedHandle extends HttpServlet {
HttpServletRequest request;
HttpServletResponse response;
DAL.Fixed fixed = new DAL.Fixed();
//通过表单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;
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”);//删除成功后跳转至管理页面
}
//车辆出场更新操作
private void setOut() throws IOException {
String fixed_id = new String(request.getParameter(“fixed_id”).getBytes(“ISO8859_1”), “UTF-8”);
SimpleDateFormat dateFormat = new SimpleDateFormat(“yyyy-MM-dd”);
String out_date = dateFormat.format(new Date());
SimpleDateFormat timeFormat = new SimpleDateFormat(“HH:mm:ss”);
String out_time = timeFormat.format(new Date());
if (fixed.setOut(fixed_id, out_date, out_time) == 1) {
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”;
if (!fixed.checkExist(fixed_id)) {
if (fixed.insertEntity(fixed_id, card_id, entry_date, entry_time, out_date, out_time) == 1) {
out.write(“”);
} else {
out.write(“”);
}
} else {
out.write(“”);
}
}
//获取对象所有数据列表
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 list = fixed.getEntity(page);//获取数据列表
request.setAttribute(“list”, list);//将数据存放到request对象中,用于转发给前台页面使用
request.setAttribute(“totalPage”, totalPage);//将totalPage存放到request对象中,用于转发给前台页面使用
request.getRequestDispatcher(“/Admin/FixedMsg.jsp”).forward(request, response);//请求转发
}
//获取未出场的车辆
private void getNoOut() 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 list = fixed.getNoOut(page);//获取数据列表
request.setAttribute(“list”, list);//将数据存放到request对象中,用于转发给前台页面使用
request.setAttribute(“totalPage”, totalPage);//将totalPage存放到request对象中,用于转发给前台页面使用
request.getRequestDispatcher(“/Admin/FixedOut.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(fixed.getPageCountByWhere(where).toString());//获取查询后的分页总数
List list = fixed.getEntityByWhere(where, page);//获取查询后的数据列表
request.setAttribute(“list”, list);//将数据存放到request对象中,用于转发给前台页面使用
request.setAttribute(“wherePage”, wherePage);
request.setAttribute(“condition”, condition);
request.setAttribute(“value”, value);
request.getRequestDispatcher(“/Admin/FixedMsg.jsp”).forward(request, response);
}
}
LoginHandle
package ServletHandle;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class LoginHandle extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setCharacterEncoding(“UTF-8”);//设置输出编码格式
response.setContentType(“text/html;charset=UTF-8”);
HttpSession session = request.getSession();
String user_id = request.getParameter(“user_id”);//获取前台url传过来的uName参数
String user_pwd = request.getParameter(“user_pwd”);//获取前台url传过来的uPwd参数
DAL.Login _login = new DAL.Login();//实例化Login对象,来至DAL包
boolean result = _login.checkLogin(user_id, user_pwd);//检查登陆用户是否合法
if (result)//登陆正确
{
session.setAttribute(“user_id”, user_id);//将用户userId保存在session对象中全局使用
String user_name = _login.getName(user_id);//获取用户名
session.setAttribute(“user_name”, user_name);
String role_id = _login.getSysLevel(user_id);
session.setAttribute(“role_id”, role_id);
request.getRequestDispatcher(“/index.jsp”).forward(request, response);
} else {//登陆错误
PrintWriter out = response.getWriter();
out.write(“”);
}
}
}
RoleHandle
package ServletHandle;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
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代表获取表中信息
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;
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) {
out.write(“”);
} else {
out.write(“”);
}
} else {
out.write(“”);
}
}
//获取对象所有数据列表
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());//获取分页总数
List list = role.getEntity(page);//获取数据列表
request.setAttribute(“list”, list);//将数据存放到request对象中,用于转发给前台页面使用
request.setAttribute(“totalPage”, totalPage);//将totalPage存放到request对象中,用于转发给前台页面使用
request.getRequestDispatcher(“/Admin/RoleMsg.jsp”).forward(request, response);//请求转发
}
//根据查询条件获取对象所有数据列表
private void getEntityByWhere() throws ServletException, IOException {
request.setCharacterEncoding(“UTF-8”);
String condition = request.getParameter(“condition”);//获取查询字段的名称
System.out.println(condition);
//String value=new String(request.getParameter(“value”).getBytes(“ISO8859_1”),“UTF-8”);//获取查询的值
String value = request.getParameter(“value”);
System.out.println("value " + value);
String where = condition + “=”" + value + “”";//拼接查询字符串
System.out.println("where " + where);
int page = request.getParameter(“page”) == null ? 1 : Integer.parseInt(request.getParameter(“page”));//获取要跳转的页面号
//System.out.println(“page +”+page );
int wherePage = Integer.parseInt(role.getPageCountByWhere(where).toString());//获取查询后的分页总数
List list = role.getEntityByWhere(where, page);//获取查询后的数据列表
System.out.println();
request.setAttribute(“list”, list);//将数据存放到request对象中,用于转发给前台页面使用
request.setAttribute(“wherePage”, wherePage);
request.setAttribute(“condition”, condition);
request.setAttribute(“value”, value);
request.getRequestDispatcher(“/Admin/RoleMsg.jsp”).forward(request, response);
}
}
SeatHandle
package ServletHandle;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.*;
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;
}
}
//通过表单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 seat_id = request.getParameter(“seat_id”);//获取前台通过get方式传过来的JId
seat.deleteEntity(seat_id);//执行删除操作
response.sendRedirect(“/Parking/SeatHandle?type=4”);//删除成功后跳转至管理页面
}
//更新数据操作
private void updateEntity() throws UnsupportedEncodingException {
String seat_id = new String(request.getParameter(“seat_id”).getBytes(“ISO8859_1”), “UTF-8”);
String seat_num = new String(request.getParameter(“seat_num”).getBytes(“ISO8859_1”), “UTF-8”);
String seat_section = new String(request.getParameter(“seat_section”).getBytes(“ISO8859_1”), “UTF-8”);
String seat_state = new String(request.getParameter(“seat_state”).getBytes(“ISO8859_1”), “UTF-8”);
String seat_tag = new String(request.getParameter(“seat_tag”).getBytes(“ISO8859_1”), “UTF-8”);
if (seat.updateEntity(seat_id, seat_num, seat_section, seat_state, seat_tag) == 1) {
try {
response.sendRedirect(“/Parking/SeatHandle?type=4”);//成功更新数据后跳转至SeatMsg.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 seat_id = dateFormat.format(new Date());
String seat_num = new String(request.getParameter(“seat_num”).getBytes(“ISO8859_1”), “UTF-8”);
String seat_section = new String(request.getParameter(“seat_section”).getBytes(“ISO8859_1”), “UTF-8”);
String seat_state = “0”;
String seat_tag = new String(request.getParameter(“seat_tag”).getBytes(“ISO8859_1”), “UTF-8”);
if (!seat.checkExist(seat_id)) {
if (seat.insertEntity(seat_id, seat_num, seat_section, seat_state, seat_tag) == 1) {
out.write(“”);
} else {
out.write(“”);
}
} else {
out.write(“”);
}
}
//获取对象所有数据列表
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(seat.getPageCount().toString());//获取分页总数
List list = seat.getEntity(page);//获取数据列表
request.setAttribute(“list”, list);//将数据存放到request对象中,用于转发给前台页面使用
request.setAttribute(“totalPage”, totalPage);//将totalPage存放到request对象中,用于转发给前台页面使用
request.getRequestDispatcher(“/Admin/SeatMsg.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”);
if (value.equals(“闲置”)) {
String where = condition + “=0”;
System.out.println(“where=” + where);
int page = request.getParameter(“page”) == null ? 1 : Integer.parseInt(request.getParameter(“page”));//获取要跳转的页面号
int wherePage = Integer.parseInt(seat.getPageCountByWhere(where).toString());//获取查询后的分页总数
List list = seat.getEntityByWhere(where, page);//获取查询后的数据列表
request.setAttribute(“list”, list);//将数据存放到request对象中,用于转发给前台页面使用
request.setAttribute(“wherePage”, wherePage);
request.setAttribute(“condition”, condition);
request.setAttribute(“value”, value);
request.getRequestDispatcher(“/Admin/SeatMsg.jsp”).forward(request, response);
}
if (value.equals(“占用”)) {
String where = condition + “=1”;
System.out.println(“where=” + where);
int page = request.getParameter(“page”) == null ? 1 : Integer.parseInt(request.getParameter(“page”));//获取要跳转的页面号
int wherePage = Integer.parseInt(seat.getPageCountByWhere(where).toString());//获取查询后的分页总数
List list = seat.getEntityByWhere(where, page);//获取查询后的数据列表
request.setAttribute(“list”, list);//将数据存放到request对象中,用于转发给前台页面使用
request.setAttribute(“wherePage”, wherePage);
request.setAttribute(“condition”, condition);
request.setAttribute(“value”, value);
request.getRequestDispatcher(“/Admin/SeatMsg.jsp”).forward(request, response);
} else {
String where = condition + “=”" + value + “”";//拼接查询字符串
int page = request.getParameter(“page”) == null ? 1 : Integer.parseInt(request.getParameter(“page”));//获取要跳转的页面号
int wherePage = Integer.parseInt(seat.getPageCountByWhere(where).toString());//获取查询后的分页总数
List list = seat.getEntityByWhere(where, page);//获取查询后的数据列表
request.setAttribute(“list”, list);//将数据存放到request对象中,用于转发给前台页面使用
request.setAttribute(“wherePage”, wherePage);
request.setAttribute(“condition”, condition);
request.setAttribute(“value”, value);
request.getRequestDispatcher(“/Admin/SeatMsg.jsp”).forward(request, response);
}
//String where=condition+“=”“+value+”“”;//拼接查询字符串
}
}
UserHandle
package ServletHandle;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.*;
public class UserHandle extends HttpServlet {
HttpServletRequest request;
HttpServletResponse response;
DAL.User user = new DAL.User();
//通过表单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;
}
}
//通过表单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”);
String newPwd = new String(request.getParameter(“NewPwd”).getBytes(“ISO8859_1”), “UTF-8”);
if (user.checkPwd(userId, oldPwd)) {
if (user.updataPwd(userId, newPwd)) {
out.write(“”);
} else {
out.write(“”);
}
} else {
out.write(“”);
}
}
//用户注册
private void register() throws UnsupportedEncodingException, IOException {
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();
//account.insertEntity(AId, UserId, “0”,“2015-12-30”);
out.write(“”);
}
} else {
out.write(“”);
}
}
//删除数据操作
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 {
response.setCharacterEncoding(“UTF-8”);
response.setContentType(“text/html;charset=UTF-8”);
PrintWriter out = response.getWriter();
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.checkExist(user_id)) {
if (user.insertEntity(user_id, role_id, user_name, real_name, user_pwd, user_phone) == 1) {
out.write(“”);
} else {
out.write(“”);
}
} else {
out.write(“”);
}
}
//获取对象所有数据列表
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 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 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);
}
}
四、其他
====
1.其他系统实现
1.JavaWeb系统系列实现
Java+Springboot+Mybatis+Bootstrap+Maven实现网上商城系统
2.JavaSwing系统系列实现
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数前端工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Web前端开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:前端)
![](https://i-blog.csdnimg.cn/blog_migrate/bd8e016f91170b64a554cda7f338572b.jpeg)
最后
由于篇幅限制,pdf文档的详解资料太全面,细节内容实在太多啦,所以只把部分知识点截图出来粗略的介绍,每个小节点里面都有更细化的内容!有需要的程序猿(媛)可以帮忙点赞+点击【学习资料】即可免费领取!
四、其他
====
1.其他系统实现
1.JavaWeb系统系列实现
Java+Springboot+Mybatis+Bootstrap+Maven实现网上商城系统
2.JavaSwing系统系列实现
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数前端工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Web前端开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
[外链图片转存中…(img-CTcqQQ7q-1712111691700)]
[外链图片转存中…(img-IzmmN4R3-1712111691701)]
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!
[外链图片转存中…(img-2UdAM1bq-1712111691701)]
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:前端)
![](https://i-blog.csdnimg.cn/blog_migrate/bd8e016f91170b64a554cda7f338572b.jpeg)
最后
由于篇幅限制,pdf文档的详解资料太全面,细节内容实在太多啦,所以只把部分知识点截图出来粗略的介绍,每个小节点里面都有更细化的内容!有需要的程序猿(媛)可以帮忙点赞+点击【学习资料】即可免费领取!
[外链图片转存中…(img-itpF6YsF-1712111691701)]
[外链图片转存中…(img-ufI6OXx4-1712111691702)]