IDEA+Java+Servlet+JSP+Mysql实现Web停车场管理系统【建议收藏】(下)

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: IDEA+Java+Servlet+JSP+Mysql实现Web停车场管理系统【建议收藏】

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("<script>alert('数据添加成功!'); location.href = '/Parking/FixedHandle?type=6';</script>");
            } else {
                out.write("<script>alert('数据添失败!'); location.href = '/Parking/FixedHandle?type=6';</script>");
            }
        } else {
            out.write("<script>alert('主键重复,数据添加失败!'); location.href = '/Parking/FixedHandle?type=4';</script>");
        }
    }
    //获取对象所有数据列表
    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对象中,用于转发给前台页面使用
        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<Object> 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<Object> 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("<script>alert('用户名或密码错误!');location.href='Login.jsp';</script>");
        }
    }
}

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("<script>alert('数据添加成功!'); location.href = '/Parking/RoleHandle?type=4';</script>");
            } else {
                out.write("<script>alert('数据添失败!'); location.href = '/Parking/RoleHandle?type=4';</script>");
            }
        } else {
            out.write("<script>alert('主键重复,数据添加失败!'); location.href = '/Parking/RoleHandle?type=4';</script>");
        }
    }
    //获取对象所有数据列表
    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<Object> 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<Object> 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("<script>alert('数据添加成功!'); location.href = '/Parking/SeatHandle?type=4';</script>");
            } else {
                out.write("<script>alert('数据添失败!'); location.href = '/Parking/SeatHandle?type=4';</script>");
            }
        } else {
            out.write("<script>alert('主键重复,数据添加失败!'); location.href = '/Parking/SeatHandle?type=4';</script>");
        }
    }
    //获取对象所有数据列表
    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<Object> 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<Object> 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<Object> 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<Object> 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("<script>alert('密码更改成功~~~');location.href='/Parking/Common/UserInfo.jsp'</script>");
            } else {
                out.write("<script>alert('密码更改失败~~~');location.href='/Parking/Common/ChagePwd.jsp'</script>");
            }
        } else {
            out.write("<script>alert('原始密码错误~~~');location.href='/Parking/Common/ChagePwd.jsp'</script>");
        }
    }
    //用户注册
    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("<script>alert('恭喜你,注册成功~'); location.href = '/Parking/Login.jsp';</script>");
            }
        } else {
            out.write("<script>alert('您注册的登陆账号已存在,请重新注册!'); location.href = '/Parking/Login.jsp';</script>");
        }
    }
    //删除数据操作
    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("<script>alert('数据添加成功!'); location.href = '/Parking/UserHandle?type=4';</script>");
            } else {
                out.write("<script>alert('数据添失败!'); location.href = '/Parking/UserHandle?type=4';</script>");
            }
        } else {
            out.write("<script>alert('主键重复,数据添加失败!'); location.href = '/Parking/UserHandle?type=4';</script>");
        }
    }
    //获取对象所有数据列表
    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);
    }
}


四、其他


1.其他系统实现


1.JavaWeb系统系列实现


Java+JSP实现学生图书管理系统


Java+JSP实现学生信息管理系统


Java+JSP实现用户信息管理系统


Java+Servlet+JSP实现航空订票系统


Java+Servlet+JSP实现新闻发布系统


Java+Servlet+JSP实现学生信息管理系统


Java+Servlet+JSP实现学生选课管理系统


Java+Servlet+JSP实现学生成绩管理系统-1


Java+Servlet+JSP实现学生成绩管理系统-2


Java+Servlet+JSP实现宠物诊所管理系统


Java+SSM+JSP实现网上考试系统


Java+SSH+JSP实现在线考试系统


Java+Springboot+Mybatis+Bootstrap+Maven实现网上商城系统


2.JavaSwing系统系列实现


Java+Swing实现斗地主游戏


Java+Swing实现图书管理系统


Java+Swing实现医院管理系统


Java+Swing实现考试管理系统


Java+Swing实现仓库管理系统-1


Java+Swing实现仓库管理系统-2


Java+Swing实现自助取款机系统


Java+Swing实现通讯录管理系统


Java+Swing实现停车场管理系统


Java+Swing实现学生信息管理系统


Java+Swing实现学生宿舍管理系统


Java+Swing实现学生选课管理系统


Java+Swing实现学生成绩管理系统


Java+Swing实现学校教材管理系统


Java+Swing实现学校教务管理系统


Java+Swing实现企业人事管理系统


Java+Swing实现电子相册管理系统


Java+Swing实现超市管理系统-TXT存储数据


Java+Swing实现自助取款机系统-TXT存储数据


Java+Swing实现宠物商店管理系统-TXT存储数据


相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
2月前
|
监控 Java API
如何使用Java语言快速开发一套智慧工地系统
使用Java开发智慧工地系统,采用Spring Cloud微服务架构和前后端分离设计,结合MySQL、MongoDB数据库及RESTful API,集成人脸识别、视频监控、设备与环境监测等功能模块,运用Spark/Flink处理大数据,ECharts/AntV G2实现数据可视化,确保系统安全与性能,采用敏捷开发模式,提供详尽文档与用户培训,支持云部署与容器化管理,快速构建高效、灵活的智慧工地解决方案。
|
3天前
|
存储 分布式计算 Hadoop
基于Java的Hadoop文件处理系统:高效分布式数据解析与存储
本文介绍了如何借鉴Hadoop的设计思想,使用Java实现其核心功能MapReduce,解决海量数据处理问题。通过类比图书馆管理系统,详细解释了Hadoop的两大组件:HDFS(分布式文件系统)和MapReduce(分布式计算模型)。具体实现了单词统计任务,并扩展支持CSV和JSON格式的数据解析。为了提升性能,引入了Combiner减少中间数据传输,以及自定义Partitioner解决数据倾斜问题。最后总结了Hadoop在大数据处理中的重要性,鼓励Java开发者学习Hadoop以拓展技术边界。
22 7
|
2月前
|
设计模式 消息中间件 搜索推荐
Java 设计模式——观察者模式:从优衣库不使用新疆棉事件看系统的动态响应
【11月更文挑战第17天】观察者模式是一种行为设计模式,定义了一对多的依赖关系,使多个观察者对象能直接监听并响应某一主题对象的状态变化。本文介绍了观察者模式的基本概念、商业系统中的应用实例,如优衣库事件中各相关方的动态响应,以及模式的优势和实际系统设计中的应用建议,包括事件驱动架构和消息队列的使用。
|
2月前
|
运维 自然语言处理 供应链
Java云HIS医院管理系统源码 病案管理、医保业务、门诊、住院、电子病历编辑器
通过门诊的申请,或者直接住院登记,通过”护士工作站“分配患者,完成后,进入医生患者列表,医生对应开具”长期医嘱“和”临时医嘱“,并在电子病历中,记录病情。病人出院时,停止长期医嘱,开具出院医嘱。进入出院审核,审核医嘱与住院通过后,病人结清缴费,完成出院。
143 4
|
2月前
|
Java 数据库连接 数据库
深入探讨Java连接池技术如何通过复用数据库连接、减少连接建立和断开的开销,从而显著提升系统性能
在Java应用开发中,数据库操作常成为性能瓶颈。本文通过问题解答形式,深入探讨Java连接池技术如何通过复用数据库连接、减少连接建立和断开的开销,从而显著提升系统性能。文章介绍了连接池的优势、选择和使用方法,以及优化配置的技巧。
54 1
|
2月前
|
JavaScript Java 项目管理
Java毕设学习 基于SpringBoot + Vue 的医院管理系统 持续给大家寻找Java毕设学习项目(附源码)
基于SpringBoot + Vue的医院管理系统,涵盖医院、患者、挂号、药物、检查、病床、排班管理和数据分析等功能。开发工具为IDEA和HBuilder X,环境需配置jdk8、Node.js14、MySQL8。文末提供源码下载链接。
|
3月前
|
移动开发 前端开发 JavaScript
java家政系统成品源码的关键特点和技术应用
家政系统成品源码是已开发完成的家政服务管理软件,支持用户注册、登录、管理个人资料,家政人员信息管理,服务项目分类,订单与预约管理,支付集成,评价与反馈,地图定位等功能。适用于各种规模的家政服务公司,采用uniapp、SpringBoot、MySQL等技术栈,确保高效管理和优质用户体验。
|
3月前
|
XML JSON API
ServiceStack:不仅仅是一个高性能Web API和微服务框架,更是一站式解决方案——深入解析其多协议支持及简便开发流程,带您体验前所未有的.NET开发效率革命
【10月更文挑战第9天】ServiceStack 是一个高性能的 Web API 和微服务框架,支持 JSON、XML、CSV 等多种数据格式。它简化了 .NET 应用的开发流程,提供了直观的 RESTful 服务构建方式。ServiceStack 支持高并发请求和复杂业务逻辑,安装简单,通过 NuGet 包管理器即可快速集成。示例代码展示了如何创建一个返回当前日期的简单服务,包括定义请求和响应 DTO、实现服务逻辑、配置路由和宿主。ServiceStack 还支持 WebSocket、SignalR 等实时通信协议,具备自动验证、自动过滤器等丰富功能,适合快速搭建高性能、可扩展的服务端应用。
209 3
|
1月前
|
前端开发 安全 JavaScript
2025年,Web3开发学习路线全指南
本文提供了一条针对Dapp应用开发的学习路线,涵盖了Web3领域的重要技术栈,如区块链基础、以太坊技术、Solidity编程、智能合约开发及安全、web3.js和ethers.js库的使用、Truffle框架等。文章首先分析了国内区块链企业的技术需求,随后详细介绍了每个技术点的学习资源和方法,旨在帮助初学者系统地掌握Dapp开发所需的知识和技能。
2025年,Web3开发学习路线全指南
|
2月前
|
设计模式 前端开发 数据库
Python Web开发:Django框架下的全栈开发实战
【10月更文挑战第27天】本文介绍了Django框架在Python Web开发中的应用,涵盖了Django与Flask等框架的比较、项目结构、模型、视图、模板和URL配置等内容,并展示了实际代码示例,帮助读者快速掌握Django全栈开发的核心技术。
228 45