基于javaweb的SSM+Maven教务选课管理系统(管理员、教师、学生)(java+jsp+maven+ssm+mysql+tomcat)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

管理员:课程、教师、学生模板的增删改查管理

教师:查看授课、成绩、打分等

学生:查看课程、选课、退课等

070123192502

540123182502

管理员

550123182502

560123182502

570123182502

580123182502

590123182502

学生

010123192502

020123192502

030123192502

教师

040123192502

050123192502

060123192502

技术框架

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

基于javaweb的SSM+Maven教务选课管理系统(管理员、教师、学生)(java+jsp+maven+ssm+mysql+tomcat)

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

/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<课程操作>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/

// 课程信息显示
@RequestMapping("/showCourse")
public String showCourse(Model model, Integer page) throws Exception {

List<CourseCustom> list = null;
//页码对象
PagingVO pagingVO = new PagingVO();
//设置总页数
pagingVO.setTotalCount(courseService.getCountCouse());
if (page == null || page == 0) {
pagingVO.setToPageNo(1);
list = courseService.findByPaging(1);
} else {
pagingVO.setToPageNo(page);
list = courseService.findByPaging(page);
}

model.addAttribute("courseList", list);
model.addAttribute("pagingVO", pagingVO);

return "admin/showCourse";

}

//添加课程
@RequestMapping(value = "/addCourse", method = {RequestMethod.GET})
public String addCourseUI(Model model) throws Exception {

List<TeacherCustom> list = teacherService.findAll();
List<College> collegeList = collegeService.finAll();

model.addAttribute("collegeList", collegeList);
model.addAttribute("teacherList", list);

return "admin/addCourse";
}

// 添加课程信息处理
@RequestMapping(value = "/addCourse", method = {RequestMethod.POST})
public String addCourse(CourseCustom courseCustom, Model model) throws Exception {

Boolean result = courseService.save(courseCustom);

if (!result) {
model.addAttribute("message", "课程号重复");
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

// 修改学生信息处理
@RequestMapping(value = "/editStudent", method = {RequestMethod.POST})
public String editStudent(StudentCustom studentCustom) throws Exception {

studentService.updataById(studentCustom.getUserid(), studentCustom);

//重定向
return "redirect:/admin/showStudent";
}

// 删除学生
@RequestMapping(value = "/removeStudent", method = {RequestMethod.GET} )
public String removeStudent(Integer id) throws Exception {
if (id == null) {
//加入没有带学生id就进来的话就返回学生显示页面
return "admin/showStudent";
}
try {
studentService.removeById(id);
userloginService.removeByName(id.toString());
} catch (Exception e) {
e.printStackTrace();
}

return "redirect:/admin/showStudent";
}

// 搜索学生
@RequestMapping(value = "selectStudent", method = {RequestMethod.POST})
public String selectStudent(String findByName, Model model) throws Exception {

List<StudentCustom> list = studentService.findByName(findByName);

model.addAttribute("studentList", list);
return "admin/showStudent";
}

/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<教师操作>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/

// 教师页面显示
@RequestMapping("/showTeacher")
public String showTeacher(Model model, Integer page) throws Exception {

List<TeacherCustom> list = null;
//页码对象
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

SelectedCourseCustom selectedCourseCustom = selectedCourseService.findOne(scc);

model.addAttribute("selectedCourse", selectedCourseCustom);

return "teacher/mark";
}

// 打分
@RequestMapping(value = "/mark", method = {RequestMethod.POST})
public String mark(SelectedCourseCustom scc) throws Exception {

selectedCourseService.updataOne(scc);

return "redirect:/teacher/gradeCourse?id="+scc.getCourseid();
}

//修改密码
@RequestMapping(value = "/passwordRest")
public String passwordRest() throws Exception {
return "teacher/passwordRest";
}

}
package com.demo.common.exception;



/**
* 全局异常处理器
* springmvc提供一个HandlerExceptionResolver接口
* 只要实现该接口,并配置到spring 容器里,该类就能
* 成为默认全局异常处理类
*
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
        throw new CustomException("未找到该名学生");
}
List<College> list = collegeService.finAll();

model.addAttribute("collegeList", list);
model.addAttribute("teacher", teacherCustom);


return "admin/editTeacher";
}

// 修改教师信息页面处理
@RequestMapping(value = "/editTeacher", method = {RequestMethod.POST})
public String editTeacher(TeacherCustom teacherCustom) throws Exception {

teacherService.updateById(teacherCustom.getUserid(), teacherCustom);

//重定向
return "redirect:/admin/showTeacher";
}

//删除教师
@RequestMapping("/removeTeacher")
public String removeTeacher(Integer id) throws Exception {
if (id == null) {
//加入没有带教师id就进来的话就返回教师显示页面
return "admin/showTeacher";
}
teacherService.removeById(id);
userloginService.removeByName(id.toString());

return "redirect:/admin/showTeacher";
}

//搜索教师
@RequestMapping(value = "selectTeacher", method = {RequestMethod.POST})
public String selectTeacher(String findByName, Model model) throws Exception {

List<TeacherCustom> list = teacherService.findByName(findByName);

model.addAttribute("teacherList", list);
return "admin/showTeacher";
}

/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<课程操作>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/

// 课程信息显示
@RequestMapping("/showCourse")
public String showCourse(Model model, Integer page) throws Exception {

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


/**
* 全局异常处理器
* springmvc提供一个HandlerExceptionResolver接口
* 只要实现该接口,并配置到spring 容器里,该类就能
* 成为默认全局异常处理类
*
* 全局异常处理器只有一个,配置多个也没用。
*/
public class CustomExceptionResolver implements HandlerExceptionResolver {

public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) {

ModelAndView modelAndView = new ModelAndView();

CustomException customException;
if (e instanceof CustomException) {
customException = (CustomException)e;
} else if (e instanceof UnknownAccountException) {
//用户名错误异常
modelAndView.addObject("message", "没有该用户");
modelAndView.setViewName("error");
return modelAndView;
} else if (e instanceof IncorrectCredentialsException) {
//用户名错误异常
modelAndView.addObject("message", "密码错误");
modelAndView.setViewName("error");
return modelAndView;
} else {
customException = new CustomException("未知错误");
}

//错误信息
String message = customException.getMessage();



//错误信息传递和错误页面跳转
modelAndView.addObject("message", message);
modelAndView.setViewName("error");


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
}

//删除教师
@RequestMapping("/removeTeacher")
public String removeTeacher(Integer id) throws Exception {
if (id == null) {
//加入没有带教师id就进来的话就返回教师显示页面
return "admin/showTeacher";
}
teacherService.removeById(id);
userloginService.removeByName(id.toString());

return "redirect:/admin/showTeacher";
}

//搜索教师
@RequestMapping(value = "selectTeacher", method = {RequestMethod.POST})
public String selectTeacher(String findByName, Model model) throws Exception {

List<TeacherCustom> list = teacherService.findByName(findByName);

model.addAttribute("teacherList", list);
return "admin/showTeacher";
}

/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<课程操作>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/

// 课程信息显示
@RequestMapping("/showCourse")
public String showCourse(Model model, Integer page) throws Exception {

List<CourseCustom> list = null;
//页码对象
PagingVO pagingVO = new PagingVO();
//设置总页数
pagingVO.setTotalCount(courseService.getCountCouse());
if (page == null || page == 0) {
pagingVO.setToPageNo(1);
list = courseService.findByPaging(1);
} else {
pagingVO.setToPageNo(page);
list = courseService.findByPaging(page);
}

model.addAttribute("courseList", list);
model.addAttribute("pagingVO", pagingVO);

return "admin/showCourse";


项目链接:
https://javayms.github.io?id=051521512602104ab
https://javayms.pages.dev?id=051521512602104ab