基于javaweb+mysql的springboot+mybatis户籍管理系统(JavaWeb JSP MySQL Servlet SSM SpringBoot Bootstrap Ajax)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
技术框架
JavaBean MVC JSP SpringBoot MyBatis MySQL CSS JavaScript Bootstrap Ajax
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
登录、注册、退出、用户模块、公告模块、户籍模块、反馈模块、迁入模块、迁出模块的增删改查管理
eclipse/MyEclipse运行:
idea运行:
*/
@RequestMapping("noticeAdd")
public void add(Notice vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
//调用Service层的增加(insert)方法
noticeService.insert(vo);
this.redirectList(request, response);
}
/**
* 删除公告
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("noticeDelete")
public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = request.getParameter("id");
noticeService.delete(Arrays.asList(id));
this.redirectList(request, response);
}
/**
* 编辑公告
*
* @param response
* @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
@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 {
vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
//调用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("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")
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 {
@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 {
vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
//调用Service层的增加(insert)方法
householdService.insert(vo);
this.redirectList(request, response);
}
* @throws IOException
*/
@RequestMapping("outmigrationEdit")
public void edit(Outmigration vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
outmigrationService.update(vo);
this.redirectList(request, response);
}
/**
* 获取迁出的详细信息(详情页面与编辑页面要显示该迁出的详情)并跳转回页面
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping({"outmigrationGet", "outmigrationEditPre"})
public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = request.getParameter("id");//取出主键id
Outmigration vo = outmigrationService.get(id);
response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(vo));
}
/**
* 根据条件查询迁出的列表并跳转回页面
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("outmigrationList")
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);//查询的关键字
//User loginUser = (User) request.getSession().getAttribute("loginUser");
* 跳转到列表页面
*
* @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);//查询的关键字
//User loginUser = (User) request.getSession().getAttribute("loginUser");
//if (!"管理员".equals(loginUser.getUserType())) {
// params.put("createBy", loginUser.getId());
//}
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");
}
}
/**
* 跳转到列表页面
*
* @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);//查询的关键字
//User loginUser = (User) request.getSession().getAttribute("loginUser");
//if (!"管理员".equals(loginUser.getUserType())) {
// params.put("createBy", loginUser.getId());
//}
Map<String, Object> map = householdService.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) householdService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
pb.setServlet("householdList");
pb.setSearchColumn(searchColumn);
pb.setKeyword(keyword);
pb.setList(list);
request.getSession().setAttribute("pageBean", pb);
request.getSession().setAttribute("list", pb.getList());
response.sendRedirect("household_list.jsp");
}
}
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) immigrationService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
pb.setServlet("immigrationList");
pb.setSearchColumn(searchColumn);
pb.setKeyword(keyword);
pb.setList(list);
request.getSession().setAttribute("pageBean", pb);
request.getSession().setAttribute("list", pb.getList());
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 {
vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
//调用Service层的增加(insert)方法
@RequestMapping("feedbackAdd")
public void add(Feedback vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
//调用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 {
String keyword = request.getParameter("keyword");
Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
params.put("searchColumn", searchColumn);//要查询的列
params.put("keyword", keyword);//查询的关键字
//User loginUser = (User) request.getSession().getAttribute("loginUser");
//if (!"管理员".equals(loginUser.getUserType())) {
// params.put("createBy", loginUser.getId());
//}
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({"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);//查询的关键字
//User loginUser = (User) request.getSession().getAttribute("loginUser");
//if (!"管理员".equals(loginUser.getUserType())) {
// params.put("createBy", loginUser.getId());
//}
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);
@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 {
vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
//调用Service层的增加(insert)方法
noticeService.insert(vo);
this.redirectList(request, response);
}
/**
* 删除公告
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("noticeDelete")
public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = request.getParameter("id");
noticeService.delete(Arrays.asList(id));
this.redirectList(request, response);
}
/**
* 编辑公告
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("noticeEdit")
public void edit(Notice vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
noticeService.update(vo);
this.redirectList(request, response);
}
/**
* 获取公告的详细信息(详情页面与编辑页面要显示该公告的详情)并跳转回页面
*/
@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);//查询的关键字
//User loginUser = (User) request.getSession().getAttribute("loginUser");
//if (!"管理员".equals(loginUser.getUserType())) {
// params.put("createBy", loginUser.getId());
//}
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");
}
}
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) householdService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
pb.setServlet("householdList");
pb.setSearchColumn(searchColumn);
pb.setKeyword(keyword);
pb.setList(list);
request.getSession().setAttribute("pageBean", pb);
request.getSession().setAttribute("list", pb.getList());
response.sendRedirect("household_list.jsp");
}
}
@Controller
@RequestMapping
public class FeedbackController {
@Autowired
private FeedbackService feedbackService;
/**
* 增加反馈
*
* @param response
* @param request
* @throws IOException
@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 {
vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
//调用Service层的增加(insert)方法
householdService.insert(vo);
this.redirectList(request, response);
}
/**
* 删除户籍
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("householdDelete")
public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = request.getParameter("id");
*/
@RequestMapping({"householdGet", "householdEditPre"})
public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = request.getParameter("id");//取出主键id
Household vo = householdService.get(id);
response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(vo));
}
/**
* 根据条件查询户籍的列表并跳转回页面
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("householdList")
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);//查询的关键字
//User loginUser = (User) request.getSession().getAttribute("loginUser");
//if (!"管理员".equals(loginUser.getUserType())) {
// params.put("createBy", loginUser.getId());
//}
Map<String, Object> map = householdService.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) householdService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
pb.setServlet("householdList");
pb.setSearchColumn(searchColumn);
@Autowired
private HouseholdService householdService;
/**
* 增加户籍
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("householdAdd")
public void add(Household vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
vo.setCreateBy(((com.demo.vo.User) request.getSession().getAttribute("loginUser")).getId());
//调用Service层的增加(insert)方法
householdService.insert(vo);
this.redirectList(request, response);
}
/**
* 删除户籍
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("householdDelete")
public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = request.getParameter("id");
householdService.delete(Arrays.asList(id));
this.redirectList(request, response);
}
/**
* 编辑户籍
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("householdEdit")
public void edit(Household vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
householdService.update(vo);
this.redirectList(request, 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);//查询的关键字
//User loginUser = (User) request.getSession().getAttribute("loginUser");
//if (!"管理员".equals(loginUser.getUserType())) {
// params.put("createBy", loginUser.getId());
//}
Map<String, Object> map = householdService.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) householdService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
pb.setServlet("householdList");
pb.setSearchColumn(searchColumn);
pb.setKeyword(keyword);
pb.setList(list);
request.getSession().setAttribute("pageBean", pb);
request.getSession().setAttribute("list", pb.getList());
response.sendRedirect("household_list.jsp");
}
}