无任何框架结构手写java学生课题设计宿舍管理系统设计与实现(项目源码+技术文档说明+视频录制+项目截图)
Posted weixin_ancenhw
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无任何框架结构手写java学生课题设计宿舍管理系统设计与实现(项目源码+技术文档说明+视频录制+项目截图)相关的知识,希望对你有一定的参考价值。
学生宿舍管理系统主要实现了基本的功能,有对宿舍的管理,宿舍楼的管理、学生用户管理,实现数据基本业务数据添加、删除,修改、查询等操作,采用了最基础servlet技术,无实现任何框架结构,前端采用了jsp、javascript、jquery, 使用idea可直接导入项目运行,采用mysql5.X数据库。
登录功能的实现代码:
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
String type = request.getParameter("type");
if ("trueLogin".equals(type)) // 执行登录的
String uname = request.getParameter("uname");
String pwd = request.getParameter("pwd");
if (uname == null || "".equals(uname.trim())
|| pwd == null || "".equals(pwd.trim()))
ResultDTO<Object> dto = ResultDTO.buildFailure("用户名或密码不能为空");
ResponseUtil.respAppJson(response,dto);
return;
ManagerDO managerDO = new ManagerDO();
managerDO.setUserName(uname);
managerDO.setPwd(pwd);
boolean b = managerService.validateManagerInfo(managerDO);
if (b)
request.getSession().setAttribute("manager",managerDO);
ResponseUtil.respAppJson(response,ResultDTO.buildEmptySuccess());
else
ResponseUtil.respAppJson(response,ResultDTO.buildFailure("用户名或密码不正确"));
else
request.getRequestDispatcher("/WEB-INF/login.jsp").forward(request,response);
学生增删改查方法
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
// 设置导航
request.setAttribute("studentActive", "active");
String type = request.getParameter("type");
if ("toManage".equals(type))
String no = request.getParameter("no");
String pageNowStr = request.getParameter("pageNow");//当前第几页
StudentRequest searchRequest = new StudentRequest();
int pageNow = 1; // 默认查第一页
if (pageNowStr != null && !"".equals(pageNowStr.trim()))
pageNow = Integer.parseInt(pageNowStr);
searchRequest.setPageNow(pageNow);
searchRequest.setStudentNo(no);
TableResult<StudentDO> tableResult = service.retrieveList(searchRequest);
tableResult.setPageNow(pageNow);
tableResult.setSearchWord(no == null ? "" : no);
// 放到request请求域中,并在studentManage.jsp中使用
request.setAttribute("tableResult", tableResult);
request.getRequestDispatcher("/WEB-INF/student/manage.jsp").forward(request, response);
else if ("toAdd".equals(type))
// 查询宿舍楼
DormitoryBuildingRequest dormitoryBuildingRequest = new DormitoryBuildingRequest();
dormitoryBuildingRequest.setPageSize(-1);
Vector<BuildingDO> vector = buildingService.getVector(dormitoryBuildingRequest);
request.setAttribute("buildings", vector);
request.getRequestDispatcher("/WEB-INF/student/add.jsp").forward(request, response);
else if ("add".equals(type))
try
// 执行学生的添加
StudentDO studentDO = buildBasicStudent(request);
boolean b = service.add(studentDO);
if (b)
ResponseUtil.respAppJson(response, ResultDTO.buildSuccess("添加成功"));
else
ResponseUtil.respAppJson(response, ResultDTO.buildFailure("添加失败"));
catch (Exception e)
e.printStackTrace();
ResponseUtil.respAppJson(response, ResultDTO.buildFailure(e.getMessage()));
else if ("toUpdate".equals(type))
String id = request.getParameter("id");
String pageNow = request.getParameter("pageNow");
StudentDO dormitoryDO = service.retrieveOneById(Long.parseLong(id));
request.setAttribute("oneDO", dormitoryDO);
request.setAttribute("pageNow", Integer.parseInt(pageNow));
// 查询出所有的宿舍楼
DormitoryBuildingRequest dormitoryBuildingRequest = new DormitoryBuildingRequest();
dormitoryBuildingRequest.setPageSize(-1);
Vector<BuildingDO> vector = buildingService.getVector(dormitoryBuildingRequest);
request.setAttribute("buildings", vector);
request.getRequestDispatcher("/WEB-INF/student/update.jsp").forward(request, response);
else if ("update".equals(type))
try
String id = request.getParameter("id");
StudentDO studentDO = buildBasicStudent(request);
studentDO.setId(Long.parseLong(id));
boolean b = service.update(studentDO);
if (b)
ResponseUtil.respAppJson(response, ResultDTO.buildSuccess("更新成功"));
else
ResponseUtil.respAppJson(response, ResultDTO.buildFailure("更新失败"));
catch (Exception e)
e.printStackTrace();
ResponseUtil.respAppJson(response, ResultDTO.buildFailure(e.getMessage()));
else if ("delete".equals(type))
String id = request.getParameter("id");
service.delete(new Long[]Long.parseLong(id));
response.sendRedirect(request.getContextPath() + "/student?type=toManage");
宿舍楼相关方法
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
//
request.setAttribute("buildingActive","active");
String type = request.getParameter("type");
if ("toManage".equals(type))
String no = request.getParameter("no");
String pageNowStr = request.getParameter("pageNow");//当前第几页
DormitoryBuildingRequest searchRequest = new DormitoryBuildingRequest();
int pageNow = 1; // 默认查第一页
if (pageNowStr != null && !"".equals(pageNowStr.trim()))
pageNow = Integer.parseInt(pageNowStr);
searchRequest.setPageNow(pageNow);
searchRequest.setNo(no);
TableResult<BuildingDO> tableResult = service.retrieveList(searchRequest);
tableResult.setPageNow(pageNow);
tableResult.setSearchWord(no == null ? "" : no);
// 放到request请求域中,并在studentManage.jsp中使用
request.setAttribute("tableResult",tableResult);
request.getRequestDispatcher("/WEB-INF/building/manage.jsp").forward(request,response);
else if("toAdd".equals(type))
request.getRequestDispatcher("/WEB-INF/building/add.jsp").forward(request,response);
else if("add".equals(type))
// 执行学生的添加
String no = request.getParameter("no");
String completedDate = request.getParameter("completedDate");
String buildingType = request.getParameter("buildingType");
BuildingDO buildingDO = new BuildingDO();
buildingDO.setNo(no);
buildingDO.setType(buildingType);
buildingDO.setCompletedDate(completedDate);
service.add(buildingDO);
response.sendRedirect(request.getContextPath()+"/building?type=toManage");
else if ("toUpdate".equals(type)) //更新
String id = request.getParameter("id");
String pageNow = request.getParameter("pageNow");
BuildingDO buildingDO = service.retrieveOneById(Long.parseLong(id));
request.setAttribute("oneDO", buildingDO);
request.setAttribute("pageNow",Integer.parseInt(pageNow));
request.getRequestDispatcher("/WEB-INF/building/update.jsp").forward(request,response);
else if ("update".equals(type))
String buildingId = request.getParameter("id");
String no = request.getParameter("no");
String completedDate = request.getParameter("completedDate");
String buildingType = request.getParameter("buildingType");
String pageNow = request.getParameter("pageNow");
// 把参数封装为对象
BuildingDO buildingDO = new BuildingDO();
buildingDO.setId(Long.parseLong(buildingId));
buildingDO.setNo(no);
buildingDO.setType(buildingType);
buildingDO.setCompletedDate(completedDate);
service.update(buildingDO);
response.sendRedirect(request.getContextPath()+"/building?type=toManage&pageNow="+pageNow);
else if ("delete".equals(type))
String buildingId = request.getParameter("id");
service.delete(new Long[]Long.parseLong(buildingId));
response.sendRedirect(request.getContextPath()+"/building?type=toManage");
宿舍楼相关方法
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
// 设置导航
request.setAttribute("dormitoryActive","active");
String type = request.getParameter("type");
if ("toManage".equals(type))
String no = request.getParameter("no");
String pageNowStr = request.getParameter("pageNow");//当前第几页
DormitoryRequest searchRequest = new DormitoryRequest();
int pageNow = 1; // 默认查第一页
if (pageNowStr != null && !"".equals(pageNowStr.trim()))
pageNow = Integer.parseInt(pageNowStr);
searchRequest.setPageNow(pageNow);
searchRequest.setNo(no);
TableResult<DormitoryDO> tableResult = service.retrieveList(searchRequest);
tableResult.setPageNow(pageNow);
tableResult.setSearchWord(no == null ? "" : no);
// 放到request请求域中,并在studentManage.jsp中使用
request.setAttribute("tableResult",tableResult);
request.getRequestDispatcher("/WEB-INF/dormitory/manage.jsp").forward(request,response);
else if("toAdd".equals(type))
DormitoryBuildingRequest dormitoryBuildingRequest = new DormitoryBuildingRequest();
dormitoryBuildingRequest.setPageSize(-1);
Vector<BuildingDO> vector = buildingService.getVector(dormitoryBuildingRequest);
request.setAttribute("buildings",vector);
request.getRequestDispatcher("/WEB-INF/dormitory/add.jsp").forward(request,re以上是关于无任何框架结构手写java学生课题设计宿舍管理系统设计与实现(项目源码+技术文档说明+视频录制+项目截图)的主要内容,如果未能解决你的问题,请参考以下文章