——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明






基于javaweb的SSM+Maven学生选课管理系统(java+ssm+bootstrap+javascript+mysql)
项目介绍
由SpringMVC+MyBatis为主要框架,mysql8.0配置主从复制实现读写分离。前端主要由bootstrap完成,背景用particles.js插件。数据库交互查询用到pagehelper分页。在添加修改相关功能时通过ajax来验证其主键是否存在可用。代码层次清晰,输入框约束较高,已配置登录拦截。 项目主要分为管理员、教师、学生三种角色; 管理员角色包含以下功能: 管理员登录,学生管理,教师管理,课程管理等功能。 教师角色包含以下功能: 登录界面,查看课程,建立课程计划,管理教学课程,成绩查询结课等功能。 学生角色包含以下功能: 登录界面,选课,确认选课,查看选课结果,退选界面,查看已修课程,管理个人信息等功能。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否Maven项目:是;
技术栈
- 后端:Spring+SpringMVC+Mybatis 2. 前端:JavaScript、jQuery、bootstrap、particles.js、ajax
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中applicationContext.xml配置文件中的数据库配置改为自己的配置;注:因为此处为读写分离的,需要配置2处; 4. 运行项目,输入localhost:8080/ 登录 管理员账号/密码:admin/admin 教师账号/密码: 0002/123456 学生账号/密码:201507021227/123456
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| }
public void pageIn(Model model, List list) { PageInfo page = new PageInfo(list, 5); model.addAttribute("pageInfo", page); }
@RequestMapping(value = "/queryy/{pn}", method = RequestMethod.GET) public String redirect(@RequestParam("serc") String serc, @RequestParam("condition") String condition, HttpServletRequest request, @PathVariable(value = "pn") String pn, Model model) { int no = Integer.parseInt(pn); List<Course> courseList = new ArrayList<Course>(); PageHelper.startPage(no, 5); request.setAttribute("serc", serc); request.setAttribute("condition", condition);
if (serc.equals("all")) {
courseList = courseService.selectCourseBySql(1, 10); pageIn(model, courseList); request.setAttribute("courseList", courseList); System.out.println(courseList); return "student/selCourse";
} else if (serc.equals("sid")) {
courseList = courseService.getByCourseCid(1, 10, condition); pageIn(model, courseList); request.setAttribute("courseList", courseList); System.out.println("sid");
return "student/selCourse";
} else if (serc.equals("nam")) { courseList = courseService.getByCourseCname(1, 10, condition); pageIn(model, courseList); request.setAttribute("courseList", courseList); System.out.println(courseList); System.out.println("cla"); return "student/selCourse";
} else if (serc.equals("col")) { courseList = courseService.getByCourseCol(1, 10, condition); pageIn(model, courseList); request.setAttribute("courseList", courseList);
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| public class StudentLoginInterceptor implements HandlerInterceptor {
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { Object sid = request.getSession().getAttribute("sid"); if (sid == null) { System.out.println("尚未登录,调到登录页面"); response.sendRedirect("/StudentInfo/index.jsp"); return false; } return true; }
@Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { System.out.println("postHandle"); }
@Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { System.out.println("afterCompletion"); }
} package net.fuzui.StudentInfo.interceptor;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| List<Course> courseList = new ArrayList<Course>(); courseList = courseService.getByCourseCid(1,10,cid); request.setAttribute("courseList", courseList);
return "admin/modiCourse"; }
@RequestMapping(value = "/moditystud/{cid}", method = RequestMethod.GET) public String update(@PathVariable("cid") String cid, Course course, Model model) { if (courseService.modifyCourse(course) != 0) { return "success"; } else { return "fail"; } }
@RequestMapping("/managecou/{pn}") public String manageCourse(HttpServletRequest request,@PathVariable(value = "pn") String pn,Model model) { int no = Integer.parseInt(pn); List<Course> courseList = new ArrayList<Course>(); PageHelper.startPage(no, 5); courseList = courseService.selectCourseBySql(1,10); pageIn(model, courseList); request.setAttribute("courseList", courseList); return "admin/queryCourse"; } }
package net.fuzui.StudentInfo.handler;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| model.addAttribute("inroduction", teacher.getIntroduction()); System.out.println(teacher.getIntroduction() + "-----------------------"); course = courseService.getByCouCid(cid); model.addAttribute("cname", course.getCname()); model.addAttribute("cid", cid); return "student/seling";
} else { System.out.println("-----进入无教师选课"); course = courseService.getByCouCid(cid); model.addAttribute("cname", course.getCname()); model.addAttribute("cid", cid); return "student/noseling"; }
}
@RequestMapping("/seling") public String confirmSelect(@RequestParam("cid") String cid, @RequestParam("sid") String sid, Model model, HttpSession httpSession, HttpServletRequest httpRequest) { if (selectCourseService.existCourse(cid, sid) != null) { httpRequest.setAttribute("msg", "已经加入过该课程,不能重复加入!"); System.out.println("已经加入过该课程,不能重复加入!"); return "fail"; } if (selectCourseService.selectCourse(cid, sid) != 0) { System.out.println(cid); System.out.println(sid); return "success"; } else { return "fail"; }
}
@RequestMapping("/backseling/{cid}") public ModelAndView backConfirmSelect(@PathVariable(value = "cid") String cid) {
return new ModelAndView(new RedirectView("/StudentInfo/StudentHandler/selqueryy/1"));
}
@RequestMapping("/selqueryy/{pn}") public String selQueryy(HttpServletRequest request, @PathVariable(value = "pn") String pn, Model model) { int no = Integer.parseInt(pn); List<Course> courseList = new ArrayList<Course>(); PageHelper.startPage(no, 5); courseList = courseService.selectCourseBySql(1, 10); pageIn(model, courseList);
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| {"历史B151","历史B152","历史B161","历史B162","历史B171","历史B172"}, {"新闻B151","新闻B152","新闻B161","新闻B162","新闻B171","新闻B172"}, {"网媒B151","网媒B152","网媒B161","网媒B162","网媒B171","网媒B172"} } };
@RequestMapping("/addStudent") public String addStudent(Student student, Model model) { int col = Integer.parseInt(student.getCollege()); int pro = Integer.parseInt(student.getProfession()); int cla = Integer.parseInt(student.getClassr()); student.setCollege(arr_belongcoll[pro]); student.setProfession(arr_belongpro[pro][col]); student.setClassr(arr_belongcla[pro][col][cla]); if (studentService.insertStudent(student) != 0) { model.addAttribute("student", student); return "success"; } else { return "fail"; }
} public void queryStu(HttpServletRequest request) { List<Student> studentList = new ArrayList<Student>(); studentList = studentService.selectStudentBySql(1,10); request.setAttribute("slist", studentList);
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
} else { return new ModelAndView(new RedirectView("/StudentInfo/fail.jsp")); }
}
@RequestMapping(value = "/querycouplan/{cid}", method = RequestMethod.GET) public String deleteStudent(@PathVariable(value = "cid") String cid, Model model, HttpSession session, HttpServletRequest request) { if(coursePlanService.existsCoursePlan(cid) != null) { request.setAttribute("msg", "该课程已经有老师代课,无法选择此课程!"); return "fail"; } model.addAttribute("cid", cid); System.out.println(cid); return "teacher/doAddCou";
}
@RequestMapping("/addquery/{pn}") public String adStudent(@PathVariable(value = "pn") String pn,Model model,HttpSession httpSession) { int no = Integer.parseInt(pn); List<Course> courseList = new ArrayList<Course>(); PageHelper.startPage(no, 5); courseList = courseService.selectCourseBySql(1,10); pageIn(model, courseList); httpSession.setAttribute("courseList", courseList); return "teacher/addCou"; }
public void pageIn(Model model,List list) { PageInfo page = new PageInfo(list, 5); model.addAttribute("pageInfo", page); }
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=262122102205200lv
https://javayms.pages.dev?id=262122102205200lv