基于javaweb+mysql的ssm+maven户籍管理系统(JavaWeb JSP MySQL Servlet SSM SpringBoot Bootstrap Ajax)

基于javaweb+mysql的ssm+maven户籍管理系统(JavaWeb JSP MySQL Servlet SSM SpringBoot Bootstrap Ajax)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

技术框架

JavaBean MVC JSP SSM(Spring SpringMVC MyBatis) Maven MySQL CSS JavaScript Bootstrap Ajax

适用

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

功能说明

登录、注册、退出、用户模块、公告模块、户籍模块、反馈模块、迁入模块、迁出模块的增删改查管理

eclipse/MyEclipse运行:

idea运行:

     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("feedbackDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        feedbackService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑反馈
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("feedbackEdit")
    public void edit(Feedback vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        feedbackService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取反馈的详细信息(详情页面与编辑页面要显示该反馈的详情)并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping({"feedbackGet", "feedbackEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");//取出主键id
        Feedback vo = feedbackService.get(id);
        response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(vo));
    }

    /**
     * 根据条件查询反馈的列表并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("feedbackList")
        response.sendRedirect("outmigration_list.jsp");
    }
}

@Controller
@RequestMapping
public class ImmigrationController {

    @Autowired
    private ImmigrationService immigrationService;

    /**
     * 增加迁入
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("immigrationAdd")
    public void add(Immigration vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        //调用Service层的增加(insert)方法
        immigrationService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除迁入
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("immigrationDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword);//查询的关键字
        Map<String, Object> map = noticeService.list(params);
        request.getSession().setAttribute("list", map.get("list"));

        Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
        String pageNum = request.getParameter("pageNum");//封装分页参数
        com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
        params.put("startIndex", pb.getStartIndex());
        params.put("pageSize", pb.getPageSize());
        List list = (List) noticeService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
        pb.setServlet("noticeList");
        pb.setSearchColumn(searchColumn);
        pb.setKeyword(keyword);
        pb.setList(list);
        request.getSession().setAttribute("pageBean", pb);
        request.getSession().setAttribute("list", pb.getList());

        response.sendRedirect("notice_list.jsp");
    }
}

@Controller
@RequestMapping
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 增加用户
     *
     * @param response

    /**
     * 编辑用户
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("userEdit")
    public void edit(User vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        userService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取用户的详细信息(详情页面与编辑页面要显示该用户的详情)并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping({"userGet", "userEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");//取出主键id
        User vo = userService.get(id);
        response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(vo));
    }

    /**
     * 根据条件查询用户的列表并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("userList")
    public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
        this.redirectList(request, response);
    }

    /**
     * 跳转到列表页面
     *
     * @param request

        response.sendRedirect("immigration_list.jsp");
    }
}

@Controller
@RequestMapping
public class HouseholdController {

    @Autowired
    private HouseholdService householdService;

    /**
     * 增加户籍
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("householdAdd")
    public void add(Household vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        //调用Service层的增加(insert)方法
        householdService.insert(vo);
        Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
        String pageNum = request.getParameter("pageNum");//封装分页参数
        com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
        params.put("startIndex", pb.getStartIndex());
        params.put("pageSize", pb.getPageSize());
        List list = (List) feedbackService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
        pb.setServlet("feedbackList");
        pb.setSearchColumn(searchColumn);
        pb.setKeyword(keyword);
        pb.setList(list);
        request.getSession().setAttribute("pageBean", pb);
        request.getSession().setAttribute("list", pb.getList());

        response.sendRedirect("feedback_list.jsp");
    }
}

@Controller
@RequestMapping
public class NoticeController {

    @Autowired
    private NoticeService noticeService;

    /**
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("feedbackAdd")
    public void add(Feedback vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        //调用Service层的增加(insert)方法
        feedbackService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除反馈
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("feedbackDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        feedbackService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑反馈
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("feedbackEdit")
    public void edit(Feedback vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        feedbackService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取反馈的详细信息(详情页面与编辑页面要显示该反馈的详情)并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping({"feedbackGet", "feedbackEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");//取出主键id
        Feedback vo = feedbackService.get(id);
        response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(vo));
    }
        Map<String, Object> map = feedbackService.list(params);
        request.getSession().setAttribute("list", map.get("list"));

        Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
        String pageNum = request.getParameter("pageNum");//封装分页参数
        com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
        params.put("startIndex", pb.getStartIndex());
        params.put("pageSize", pb.getPageSize());
        List list = (List) feedbackService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
        pb.setServlet("feedbackList");
        pb.setSearchColumn(searchColumn);
        pb.setKeyword(keyword);
        pb.setList(list);
        request.getSession().setAttribute("pageBean", pb);
        request.getSession().setAttribute("list", pb.getList());

        response.sendRedirect("feedback_list.jsp");
    }
}

@Controller
@RequestMapping
public class NoticeController {

    @Autowired
    private NoticeService noticeService;

    /**
     * 增加公告
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("noticeAdd")
    public void add(Notice vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
     * @param request
     * @throws IOException
     */
    @RequestMapping("noticeEdit")
    public void edit(Notice vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        noticeService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取公告的详细信息(详情页面与编辑页面要显示该公告的详情)并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping({"noticeGet", "noticeEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");//取出主键id
        Notice vo = noticeService.get(id);
        response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(vo));
    }

    /**
     * 根据条件查询公告的列表并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("noticeList")
    public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
        this.redirectList(request, response);
    }

    /**
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword);//查询的关键字
        Map<String, Object> map = noticeService.list(params);
        request.getSession().setAttribute("list", map.get("list"));

        Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
        String pageNum = request.getParameter("pageNum");//封装分页参数

@Controller
@RequestMapping
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 增加用户
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("userAdd")
    public void add(User vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        //调用Service层的增加(insert)方法
        userService.insert(vo);
        this.redirectList(request, response);
    }

    /**
     * 删除用户
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("userDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        userService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑用户
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("userEdit")
    public void edit(User vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        userService.update(vo);
        this.redirectList(request, response);
    public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
        this.redirectList(request, response);
    }

    /**
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword);//查询的关键字
        Map<String, Object> map = outmigrationService.list(params);
        request.getSession().setAttribute("list", map.get("list"));

        Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
        String pageNum = request.getParameter("pageNum");//封装分页参数
        com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
        params.put("startIndex", pb.getStartIndex());
        params.put("pageSize", pb.getPageSize());
        List list = (List) outmigrationService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
        pb.setServlet("outmigrationList");
        pb.setSearchColumn(searchColumn);
        pb.setKeyword(keyword);
        pb.setList(list);
        request.getSession().setAttribute("pageBean", pb);
        request.getSession().setAttribute("list", pb.getList());

        response.sendRedirect("outmigration_list.jsp");
    }
}

     */
    @RequestMapping("userDelete")
    public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");
        userService.delete(Arrays.asList(id));
        this.redirectList(request, response);
    }

    /**
     * 编辑用户
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("userEdit")
    public void edit(User vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
        userService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取用户的详细信息(详情页面与编辑页面要显示该用户的详情)并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping({"userGet", "userEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");//取出主键id
        User vo = userService.get(id);
        response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(vo));
    }

    /**
     * 根据条件查询用户的列表并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    private UserService userService;

    @RequestMapping("authLogin")
    public void login(HttpServletResponse response, HttpServletRequest request) throws IOException, ServletException {
        String username = request.getParameter("username");
        String password = request.getParameter("password");

        String validationCode = request.getParameter("validationCode");
        if (validationCode != null && !validationCode.equals(request.getSession().getAttribute("validationCode"))) {//验证码不通过
            request.getSession().setAttribute("alert_msg", "错误:验证码不正确!");
            request.getRequestDispatcher("login.jsp").forward(request, response);
            return;
        }

        Map<String, Object> params = new HashMap();
        
        
        List<User> list = (List<User>) userService.list(params).get("list");
        for (User user : list) {
            if (user.getUsername().equals(username) && user.getPassword().equals(password)) {//找到这个管理员了
                request.getSession().setAttribute("loginUser", user);
				request.getSession().setMaxInactiveInterval(Integer.MAX_VALUE);
                request.getRequestDispatcher("userList").forward(request, response);
                return;
            }
        }
        request.getSession().setAttribute("alert_msg", "错误:用户名或密码错误!");
        request.getRequestDispatcher("login.jsp").forward(request, response);
    }

    @RequestMapping("authRegister")
    public void register(HttpServletResponse response, HttpServletRequest request) throws IOException, ServletException {
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        System.out.println("username=" + username);
        System.out.println("password=" + password);

        Map<String, Object> params = new HashMap();
        
        
        params.put("startIndex", 0);
        params.put("pageSize", Long.MAX_VALUE);
        List<User> list = (List<User>) userService.list(params).get("list");
        for (User user : list) {
            if (user.getUsername().equals(username) /*&& user.getPassword().equals(password)*/) {//说明该用户名已存在,必须换个用户名才能注册
                request.getSession().setAttribute("alert_msg", "错误:用户名已存在!");
                request.getRequestDispatcher("register.jsp").forward(request, response);
                return;
        request.getSession().setAttribute("list", map.get("list"));

        Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
        String pageNum = request.getParameter("pageNum");//封装分页参数
        com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
        params.put("startIndex", pb.getStartIndex());
        params.put("pageSize", pb.getPageSize());
        List list = (List) noticeService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
        pb.setServlet("noticeList");
        pb.setSearchColumn(searchColumn);
        pb.setKeyword(keyword);
        pb.setList(list);
        request.getSession().setAttribute("pageBean", pb);
        request.getSession().setAttribute("list", pb.getList());

        response.sendRedirect("notice_list.jsp");
    }
}

@Controller
@RequestMapping
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 增加用户
     *
     * @param response
     * @param request
     * @throws IOException
     */
        immigrationService.update(vo);
        this.redirectList(request, response);
    }

    /**
     * 获取迁入的详细信息(详情页面与编辑页面要显示该迁入的详情)并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping({"immigrationGet", "immigrationEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");//取出主键id
        Immigration vo = immigrationService.get(id);
        response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(vo));
    }

    /**
     * 根据条件查询迁入的列表并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("immigrationList")
    public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
        this.redirectList(request, response);
    }

    /**
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping({"feedbackGet", "feedbackEditPre"})
    public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
        Serializable id = request.getParameter("id");//取出主键id
        Feedback vo = feedbackService.get(id);
        response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(vo));
    }

    /**
     * 根据条件查询反馈的列表并跳转回页面
     *
     * @param response
     * @param request
     * @throws IOException
     */
    @RequestMapping("feedbackList")
    public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
        this.redirectList(request, response);
    }

    /**
     * 跳转到列表页面
     *
     * @param request
     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword);//查询的关键字
        Map<String, Object> map = feedbackService.list(params);
        request.getSession().setAttribute("list", map.get("list"));

        Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
        String pageNum = request.getParameter("pageNum");//封装分页参数
        com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
        params.put("startIndex", pb.getStartIndex());
        params.put("pageSize", pb.getPageSize());
        List list = (List) feedbackService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
        pb.setServlet("feedbackList");
        pb.setSearchColumn(searchColumn);
        pb.setKeyword(keyword);
        pb.setList(list);
        request.getSession().setAttribute("pageBean", pb);
        request.getSession().setAttribute("list", pb.getList());

     * @param response
     */
    private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
        //查询列和关键字
        String searchColumn = request.getParameter("searchColumn");
        String keyword = request.getParameter("keyword");
        Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
        params.put("searchColumn", searchColumn);//要查询的列
        params.put("keyword", keyword);//查询的关键字
        Map<String, Object> map = userService.list(params);
        request.getSession().setAttribute("list", map.get("list"));

        Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
        String pageNum = request.getParameter("pageNum");//封装分页参数
        com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
        params.put("startIndex", pb.getStartIndex());
        params.put("pageSize", pb.getPageSize());
        List list = (List) userService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
        pb.setServlet("userList");
        pb.setSearchColumn(searchColumn);
        pb.setKeyword(keyword);
        pb.setList(list);
        request.getSession().setAttribute("pageBean", pb);
        request.getSession().setAttribute("list", pb.getList());

        response.sendRedirect("user_list.jsp");
    }
}

/**
 * 拦截器
 */
public class LoginInterceptor implements HandlerInterceptor {

    //@Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {

请添加图片描述

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值