基于javaweb+mysql的jsp+servlet工资管理系统(java+servlet+jsp+mysql+tomcat)

基于javaweb+mysql的jsp+servlet工资管理系统(java+servlet+jsp+mysql+tomcat)

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb的JSP+Servlet工资管理系统(java+servlet+jsp+mysql+tomcat)

登录:

admin 123456

                req.getRequestDispatcher("/WEB-INF/jsp/message.jsp").forward(req, resp);
                break;
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}

@WebServlet({"/salary", "/salary/retrieve"})
public class SalaryServlet extends HttpServlet {

    private SalaryService service = new SalaryService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        HttpSession session = req.getSession();
        String path = req.getServletPath();
        switch (path){
            case "/salary":{
                List<Salary> salaries = service.getAllSalaries();
                req.setAttribute("salaries", salaries);
                req.getRequestDispatcher("/WEB-INF/jsp/salary/salaryInfo.jsp").forward(req, resp);
                break;
            }
            case "/salary/retrieve": {
                String queryDepartment = req.getParameter("department");
                String queryMonth = req.getParameter("month");
                String queryName = req.getParameter("name");
                if(queryMonth.equals("所有月份")){
                } else {
                    session.setAttribute("errMessage", errMessage);
                }
                resp.sendRedirect("/staff/info");
                break;
            }
            case "/staff/info":
                req.getRequestDispatcher("/WEB-INF/jsp/message.jsp").forward(req, resp);
                break;
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}

@WebServlet({"/salary", "/salary/retrieve"})
public class SalaryServlet extends HttpServlet {

    private SalaryService service = new SalaryService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        HttpSession session = req.getSession();
        String path = req.getServletPath();
        switch (path){
            case "/salary":{
                List<Salary> salaries = service.getAllSalaries();
                req.setAttribute("salaries", salaries);
                req.getRequestDispatcher("/WEB-INF/jsp/salary/salaryInfo.jsp").forward(req, resp);
                break;
            }
            }
            case "/staff/create":{
                session.removeAttribute("staff");
                Object obj = session.getAttribute("staff");
                if (obj == null){
                    Staff staff = new Staff();
                    session.setAttribute("staff",staff);
                }
                req.getRequestDispatcher("/WEB-INF/jsp/staff/editInfo.jsp").forward(req, resp);
                break;
            }
            case "/staff/retrieve": {
                String queryDepartment = req.getParameter("staffDepartment");
                //System.out.println(queryDepartment);
                String queryName = req.getParameter("name");
                if(queryDepartment.equals("所有部门")){
                    if(queryName.equals("所有员工")){
                        List<Staff> staffs = service.getAllStaffs();
                        req.setAttribute("staffs", staffs);
                    }
                    else if (queryName != null && queryName.trim().length() > 0) {
                        List<Staff> staffs = service.getStaffsByName(queryName);
                        req.setAttribute("staffs", staffs);
                    }
                }else{
                    if(queryName.equals("所有员工")){
                        List<Staff> staffs = service.getStaffsByDepartment(queryDepartment);
                        req.setAttribute("staffs", staffs);
                    }else{
                        List<Staff> staffs = service.getStaffsByNameAndDepartment(queryName,queryDepartment);
                        req.setAttribute("staffs", staffs);
                    }
                }
                req.getRequestDispatcher("/WEB-INF/jsp/staff/info.jsp").forward(req, resp);
                break;
            }
            case "/staff/update":
            case "/staff/delete": {
                String errMessage = null;
                String idStr = req.getParameter("id");
                if (idStr != null && idStr.matches("[0-9]+")) {
                    Staff staff = service.getStaff(Integer.parseInt(idStr));
                    if (staff == null) {
                        errMessage = "没有指定编号的员工!";
                    } else {
                        if ("/staff/update".equals(path)) {
                            session.setAttribute("staff", staff);
                            req.getRequestDispatcher("/WEB-INF/jsp/staff/editInfo.jsp").forward(req, resp);
                        } else {
                            errMessage = service.deleteStaff(staff.getId());
                        if(queryName.equals("所有员工")){
                            List<Status> statuses = service.getStatusByMonth(Integer.parseInt(queryMonth));
                            req.setAttribute("statuses", statuses);
                        }else{
                            Status status = service.getStatusByNameAndMonth(queryName,Integer.parseInt(queryMonth));
                            req.setAttribute("status", status);
                        }
                    }else{
                        if(queryName.equals("所有员工")){
                            List<Status> statuses = service.getStatusesByDepartmentAndMonth(queryDepartment,Integer.parseInt(queryMonth));
                            req.setAttribute("statuses", statuses);
                        }else{
                            List<Status> statuses = service.getStatusesByNameMonthAndDepartment(queryName,Integer.parseInt(queryMonth),queryDepartment);
                            req.setAttribute("statuses", statuses);
                        }
                    }
                }
                req.getRequestDispatcher("/WEB-INF/jsp/employStatus/statusInfo.jsp").forward(req, resp);
                break;
            }
            case "/status/update":
            case "/status/delete": {
                String errMessage = null;
                String nameStr = req.getParameter("name");
                String monthStr = req.getParameter("month");
                System.out.println(nameStr+monthStr);
                if (nameStr != null && monthStr != null && monthStr.matches("[0-9]+")) {
                    Status status = service.getStatusByNameAndMonth(nameStr,Integer.parseInt(monthStr));
                    if (status == null) {
                        errMessage = "没有指定编号的员工!";
                    } else {
                        if ("/status/update".equals(path)) {
                            session.setAttribute("status", status);
                            req.getRequestDispatcher("/WEB-INF/jsp/employStatus/editInfo.jsp").forward(req, resp);
                        } else {
                            errMessage = service.deleteStatus(status.getName(),status.getMonth());
                            if (errMessage == null) {
                                session.setAttribute("message", "员工工作信息删除成功!");
                            }
                        }
                    }
                } else {
                    errMessage = "员工工作信息参数格式错误!";
                }
                if (errMessage != null) {
                    session.setAttribute("errMessage", errMessage);
                }
                resp.sendRedirect("/status/info");
                            session.setAttribute("staff", staff);
                            req.getRequestDispatcher("/WEB-INF/jsp/staff/editInfo.jsp").forward(req, resp);
                        } else {
                            errMessage = service.deleteStaff(staff.getId());
                            if (errMessage == null) {
                                session.setAttribute("message", "员工信息删除成功!");
                            }
                        }
                    }
                } else {
                    errMessage = "员工设定参数格式错误!";
                }
                if (errMessage != null) {
                    session.setAttribute("errMessage", errMessage);
                }
                resp.sendRedirect("/staff/info");
                break;
            }
            case "/staff/save": {
                Staff staff = new Staff();
                staff.setId(Integer.parseInt(req.getParameter("id")));
                staff.setName(req.getParameter("name"));
                staff.setStaffDepartment(req.getParameter("staffDepartment"));
                staff.setStaffDuty(req.getParameter("staffDuty"));
                String errMessage = service.UpdateStaff(staff);
                System.out.println(errMessage);
                if (errMessage == null) {
                    session.setAttribute("message", "员工信息保存成功!");
                } else {
                    session.setAttribute("errMessage", errMessage);
                }
                resp.sendRedirect("/staff/info");
                break;
            }
            case "/staff/info":
                req.getRequestDispatcher("/WEB-INF/jsp/message.jsp").forward(req, resp);
                break;
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}

                    if(queryName.equals("所有员工")){
                        List<Staff> staffs = service.getAllStaffs();
                        req.setAttribute("staffs", staffs);
                    }
                    else if (queryName != null && queryName.trim().length() > 0) {
                        List<Staff> staffs = service.getStaffsByName(queryName);
                        req.setAttribute("staffs", staffs);
                    }
                }else{
                    if(queryName.equals("所有员工")){
                        List<Staff> staffs = service.getStaffsByDepartment(queryDepartment);
                        req.setAttribute("staffs", staffs);
                    }else{
                        List<Staff> staffs = service.getStaffsByNameAndDepartment(queryName,queryDepartment);
                        req.setAttribute("staffs", staffs);
                    }
                }
                req.getRequestDispatcher("/WEB-INF/jsp/staff/info.jsp").forward(req, resp);
                break;
            }
            case "/staff/update":
            case "/staff/delete": {
                String errMessage = null;
                String idStr = req.getParameter("id");
                if (idStr != null && idStr.matches("[0-9]+")) {
                    Staff staff = service.getStaff(Integer.parseInt(idStr));
                    if (staff == null) {
                        errMessage = "没有指定编号的员工!";
                    } else {
                        if ("/staff/update".equals(path)) {
                            session.setAttribute("staff", staff);
                            req.getRequestDispatcher("/WEB-INF/jsp/staff/editInfo.jsp").forward(req, resp);
                        } else {
                            errMessage = service.deleteStaff(staff.getId());
                            if (errMessage == null) {
                                session.setAttribute("message", "员工信息删除成功!");
                            }
                        }
                    }
                } else {
                            session.setAttribute("staff", staff);
                            req.getRequestDispatcher("/WEB-INF/jsp/staff/editInfo.jsp").forward(req, resp);
                        } else {
                            errMessage = service.deleteStaff(staff.getId());
                            if (errMessage == null) {
                                session.setAttribute("message", "员工信息删除成功!");
                            }
                        }
                    }
                } else {
                    errMessage = "员工设定参数格式错误!";
                }
                if (errMessage != null) {
                    session.setAttribute("errMessage", errMessage);
                }
                resp.sendRedirect("/staff/info");
                break;
            }
            case "/staff/save": {
                Staff staff = new Staff();
                staff.setId(Integer.parseInt(req.getParameter("id")));
                staff.setName(req.getParameter("name"));
                staff.setStaffDepartment(req.getParameter("staffDepartment"));
                staff.setStaffDuty(req.getParameter("staffDuty"));
                String errMessage = service.UpdateStaff(staff);
                System.out.println(errMessage);
                if (errMessage == null) {
                    session.setAttribute("message", "员工信息保存成功!");
                } else {
                    session.setAttribute("errMessage", errMessage);
                }
                resp.sendRedirect("/staff/info");
                break;
            }
            case "/staff/info":
                req.getRequestDispatcher("/WEB-INF/jsp/message.jsp").forward(req, resp);
                break;
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
                }
                resp.sendRedirect("/staff/info");
                break;
            }
            case "/staff/info":
                req.getRequestDispatcher("/WEB-INF/jsp/message.jsp").forward(req, resp);
                break;
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}

@WebServlet({"/salary", "/salary/retrieve"})
public class SalaryServlet extends HttpServlet {

    private SalaryService service = new SalaryService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        HttpSession session = req.getSession();
        String path = req.getServletPath();
        switch (path){
            case "/salary":{
                List<Salary> salaries = service.getAllSalaries();
                req.setAttribute("salaries", salaries);
                req.getRequestDispatcher("/WEB-INF/jsp/salary/salaryInfo.jsp").forward(req, resp);
                break;
            }
            case "/salary/retrieve": {
                String queryDepartment = req.getParameter("department");
                String queryMonth = req.getParameter("month");
                String queryName = req.getParameter("name");
                if(queryMonth.equals("所有月份")){
                    if(queryDepartment.equals("所有部门")){
                    session.setAttribute("errMessage", errMessage);
                }
                resp.sendRedirect("/staff/info");
                break;
            }
            case "/staff/info":
                req.getRequestDispatcher("/WEB-INF/jsp/message.jsp").forward(req, resp);
                break;
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}

@WebServlet({"/salary", "/salary/retrieve"})
public class SalaryServlet extends HttpServlet {

    private SalaryService service = new SalaryService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        HttpSession session = req.getSession();
        String path = req.getServletPath();
        switch (path){
            case "/salary":{
                List<Salary> salaries = service.getAllSalaries();
                req.setAttribute("salaries", salaries);
                req.getRequestDispatcher("/WEB-INF/jsp/salary/salaryInfo.jsp").forward(req, resp);
                break;
            }
            case "/salary/retrieve": {
                String queryDepartment = req.getParameter("department");
                String queryMonth = req.getParameter("month");
                String queryName = req.getParameter("name");
                if(queryMonth.equals("所有月份")){

@WebServlet({"/duty", "/duty/update", "/duty/save", "/duty/info"})
public class DutyServlet extends HttpServlet {

    private DutyService service = new DutyService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        HttpSession session = req.getSession();
        String path = req.getServletPath();
        switch (path){
            case "/duty":{

                List<Duty> duties = service.getAllDuties();
                req.setAttribute("duties", duties);
                req.getRequestDispatcher("/WEB-INF/jsp/duty/dutyInfo.jsp").forward(req, resp);
                break;
            }

            case "/duty/update": {
                String errMessage = null;
                String idStr = req.getParameter("id");
                if (idStr != null && idStr.matches("[0-9]+")) {
                    Duty duty = service.getDuty(Integer.parseInt(idStr));
                    session.setAttribute("duty", duty);
                    req.getRequestDispatcher("/WEB-INF/jsp/duty/editInfo.jsp").forward(req, resp);
                } else {
                    errMessage = "职务设置参数格式错误!";
                }
                if (errMessage != null) {
                    session.setAttribute("errMessage", errMessage);
                }
                resp.sendRedirect("/duty/info");
                break;
            }
            case "/duty/save": {
                Duty duty = new Duty();
                duty.setId(Integer.parseInt(req.getParameter("id")));
                duty.setName(req.getParameter("name"));
}

@WebServlet({"/salary", "/salary/retrieve"})
public class SalaryServlet extends HttpServlet {

    private SalaryService service = new SalaryService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        HttpSession session = req.getSession();
        String path = req.getServletPath();
        switch (path){
            case "/salary":{
                List<Salary> salaries = service.getAllSalaries();
                req.setAttribute("salaries", salaries);
                req.getRequestDispatcher("/WEB-INF/jsp/salary/salaryInfo.jsp").forward(req, resp);
                break;
            }
            case "/salary/retrieve": {
                String queryDepartment = req.getParameter("department");
                String queryMonth = req.getParameter("month");
                String queryName = req.getParameter("name");
                if(queryMonth.equals("所有月份")){
                    if(queryDepartment.equals("所有部门")){
                        if(queryName.equals("所有员工")){
                            List<Salary> salaries = service.getAllSalaries();
                            req.setAttribute("salaries", salaries);
                        }else{
                            List<Salary> salaries = service.getSalariesByName(queryName);
                            req.setAttribute("salaries", salaries);
                        }
                    }else{
                        if(queryName.equals("所有员工")){
                            List<Salary> salaries = service.getSalariesByDepartment(queryDepartment);
                List<Status> statuses = service.getAllStatuses();
                req.setAttribute("statuses", statuses);
                req.getRequestDispatcher("/WEB-INF/jsp/employStatus/statusInfo.jsp").forward(req, resp);
                break;
            }
            case "/status/create":{
                session.removeAttribute("status");
                Object obj = session.getAttribute("status");
                System.out.println(obj);
                if (obj == null){
                    Status status = new Status();
                    session.setAttribute("status",status);
                }
                req.getRequestDispatcher("/WEB-INF/jsp/employStatus/editInfo.jsp").forward(req, resp);
                break;
            }
            case "/status/retrieve": {
                String queryDepartment = req.getParameter("staffDepartment");
                String queryMonth = req.getParameter("month");
                String queryName = req.getParameter("name");
                if(queryMonth.equals("所有月份")){
                    if(queryDepartment.equals("所有部门")){
                        if(queryName.equals("所有员工")){
                            List<Status> statuses = service.getAllStatuses();
                            req.setAttribute("statuses", statuses);
                        }else{
                            List<Status> statuses = service.getStatusByName(queryName);
                            req.setAttribute("statuses", statuses);
                        }
                    }else{
                        if(queryName.equals("所有员工")){
                            List<Status> statuses = service.getStatusByDepartment(queryDepartment);
                            req.setAttribute("statuses", statuses);
                        }else{
                            List<Status> statuses = service.getStatusesByDepartmentAndName(queryDepartment, queryName);
                            req.setAttribute("statuses", statuses);
                        }
                    }
                }else{
                    if(queryDepartment.equals("所有部门")){
                        if(queryName.equals("所有员工")){
                            List<Status> statuses = service.getStatusByMonth(Integer.parseInt(queryMonth));
                            req.setAttribute("statuses", statuses);
                        }else{
                            Status status = service.getStatusByNameAndMonth(queryName,Integer.parseInt(queryMonth));
                            req.setAttribute("status", status);
                        }
                    }else{
                        if(queryName.equals("所有员工")){
                            List<Status> statuses = service.getStatusesByDepartmentAndMonth(queryDepartment,Integer.parseInt(queryMonth));
                            req.setAttribute("statuses", statuses);
                        }else{
                            List<Status> statuses = service.getStatusByMonth(Integer.parseInt(queryMonth));
                            req.setAttribute("statuses", statuses);
                        }else{
                            Status status = service.getStatusByNameAndMonth(queryName,Integer.parseInt(queryMonth));
                            req.setAttribute("status", status);
                        }
                    }else{
                        if(queryName.equals("所有员工")){
                            List<Status> statuses = service.getStatusesByDepartmentAndMonth(queryDepartment,Integer.parseInt(queryMonth));
                            req.setAttribute("statuses", statuses);
                        }else{
                            List<Status> statuses = service.getStatusesByNameMonthAndDepartment(queryName,Integer.parseInt(queryMonth),queryDepartment);
                            req.setAttribute("statuses", statuses);
                        }
                    }
                }
                req.getRequestDispatcher("/WEB-INF/jsp/employStatus/statusInfo.jsp").forward(req, resp);
                break;
            }
            case "/status/update":
            case "/status/delete": {
                String errMessage = null;
                String nameStr = req.getParameter("name");
                String monthStr = req.getParameter("month");
                System.out.println(nameStr+monthStr);
                if (nameStr != null && monthStr != null && monthStr.matches("[0-9]+")) {
                    Status status = service.getStatusByNameAndMonth(nameStr,Integer.parseInt(monthStr));
                    if (status == null) {
                        errMessage = "没有指定编号的员工!";
                    } else {
                        if ("/status/update".equals(path)) {
                            session.setAttribute("status", status);
                            req.getRequestDispatcher("/WEB-INF/jsp/employStatus/editInfo.jsp").forward(req, resp);
                        } else {
                            errMessage = service.deleteStatus(status.getName(),status.getMonth());
                            if (errMessage == null) {
                                session.setAttribute("message", "员工工作信息删除成功!");
                            }
                        }
                    }
                } else {
                    errMessage = "员工工作信息参数格式错误!";
                }
                if (errMessage != null) {
                    session.setAttribute("errMessage", errMessage);
                    Duty duty = service.getDuty(Integer.parseInt(idStr));
                    session.setAttribute("duty", duty);
                    req.getRequestDispatcher("/WEB-INF/jsp/duty/editInfo.jsp").forward(req, resp);
                } else {
                    errMessage = "职务设置参数格式错误!";
                }
                if (errMessage != null) {
                    session.setAttribute("errMessage", errMessage);
                }
                resp.sendRedirect("/duty/info");
                break;
            }
            case "/duty/save": {
                Duty duty = new Duty();
                duty.setId(Integer.parseInt(req.getParameter("id")));
                duty.setName(req.getParameter("name"));
                duty.setBaseSalary(Integer.parseInt(req.getParameter("baseSalary")));
                String errMessage = service.UpdateDuty(duty);
                System.out.println(errMessage);
                if (errMessage == null) {
                    session.setAttribute("message", "职务更新保存成功!");
                } else {
                    session.setAttribute("errMessage", errMessage);
                }
                resp.sendRedirect("/duty/info");
                break;
            }
            case "/duty/info":
                req.getRequestDispatcher("/WEB-INF/jsp/message.jsp").forward(req, resp);
                break;
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}

@WebServlet("/LoginServlet")
public class LoginServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                            req.setAttribute("status", status);
                        }
                    }else{
                        if(queryName.equals("所有员工")){
                            List<Status> statuses = service.getStatusesByDepartmentAndMonth(queryDepartment,Integer.parseInt(queryMonth));
                            req.setAttribute("statuses", statuses);
                        }else{
                            List<Status> statuses = service.getStatusesByNameMonthAndDepartment(queryName,Integer.parseInt(queryMonth),queryDepartment);
                            req.setAttribute("statuses", statuses);
                        }
                    }
                }
                req.getRequestDispatcher("/WEB-INF/jsp/employStatus/statusInfo.jsp").forward(req, resp);
                break;
            }
            case "/status/update":
            case "/status/delete": {
                String errMessage = null;
                String nameStr = req.getParameter("name");
                String monthStr = req.getParameter("month");
                System.out.println(nameStr+monthStr);
                if (nameStr != null && monthStr != null && monthStr.matches("[0-9]+")) {
                    Status status = service.getStatusByNameAndMonth(nameStr,Integer.parseInt(monthStr));
                    if (status == null) {
                        errMessage = "没有指定编号的员工!";
                    } else {
                        if ("/status/update".equals(path)) {
                            session.setAttribute("status", status);
                            req.getRequestDispatcher("/WEB-INF/jsp/employStatus/editInfo.jsp").forward(req, resp);
                        } else {
                            errMessage = service.deleteStatus(status.getName(),status.getMonth());
                            if (errMessage == null) {
                                session.setAttribute("message", "员工工作信息删除成功!");
                            }
                        }
                    }
                } else {
                    errMessage = "员工工作信息参数格式错误!";
                }
                if (errMessage != null) {
            case "/staff/save": {
                Staff staff = new Staff();
                staff.setId(Integer.parseInt(req.getParameter("id")));
                staff.setName(req.getParameter("name"));
                staff.setStaffDepartment(req.getParameter("staffDepartment"));
                staff.setStaffDuty(req.getParameter("staffDuty"));
                String errMessage = service.UpdateStaff(staff);
                System.out.println(errMessage);
                if (errMessage == null) {
                    session.setAttribute("message", "员工信息保存成功!");
                } else {
                    session.setAttribute("errMessage", errMessage);
                }
                resp.sendRedirect("/staff/info");
                break;
            }
            case "/staff/info":
                req.getRequestDispatcher("/WEB-INF/jsp/message.jsp").forward(req, resp);
                break;
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}

@WebServlet({"/salary", "/salary/retrieve"})
public class SalaryServlet extends HttpServlet {

    private SalaryService service = new SalaryService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        HttpSession session = req.getSession();
                    session.setAttribute("duty", duty);
                    req.getRequestDispatcher("/WEB-INF/jsp/duty/editInfo.jsp").forward(req, resp);
                } else {
                    errMessage = "职务设置参数格式错误!";
                }
                if (errMessage != null) {
                    session.setAttribute("errMessage", errMessage);
                }
                resp.sendRedirect("/duty/info");
                break;
            }
            case "/duty/save": {
                Duty duty = new Duty();
                duty.setId(Integer.parseInt(req.getParameter("id")));
                duty.setName(req.getParameter("name"));
                duty.setBaseSalary(Integer.parseInt(req.getParameter("baseSalary")));
                String errMessage = service.UpdateDuty(duty);
                System.out.println(errMessage);
                if (errMessage == null) {
                    session.setAttribute("message", "职务更新保存成功!");
                } else {
                    session.setAttribute("errMessage", errMessage);
                }
                resp.sendRedirect("/duty/info");
                break;
            }
            case "/duty/info":
                req.getRequestDispatcher("/WEB-INF/jsp/message.jsp").forward(req, resp);
                break;
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值