作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
管理员角色包含以下功能:
管理员登录,修改个人资料,修改密码,用户管理,班级管理,科目管理,教务老师管理,任课老师管理,学生管理,成绩管理等功能。
由于本程序规模不大,可供课程设计,毕业设计学习演示之用
更多项目源码,请到“源码空间站”,地址:http://www.shuyue.fun/
环境需要
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.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 5.7/8.0等版本均可;
技术栈
1. 后端:Spring springmvc mybatis
2. 前端:JSP+css+javascript+h-ui
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,修改配置,运行项目;
3. 将项目中spring-mvc.xml配置文件中的数据库配置改为自己的配置,然后运行;
4. 运行成功后,在浏览器中输入:http://localhost:8080/ssm_xscj_sys/
管理员账号密码:admin/admin
运行截图
代码相关
登录管理控制器
@Controller
public class LoginController {
//登录跳转
@RequestMapping(value = "/login", method = {RequestMethod.GET})
public String loginUI() throws Exception {
return "../../login";
}
//登录表单处理
@RequestMapping(value = "/login", method = {RequestMethod.POST})
public String login(Userlogin userlogin) throws Exception {
//Shiro实现登录
UsernamePasswordToken token = new UsernamePasswordToken(userlogin.getUsername(),
userlogin.getPassword());
Subject subject = SecurityUtils.getSubject();
//如果获取不到用户名就是登录失败,但登录失败的话,会直接抛出异常
subject.login(token);
if (subject.hasRole("admin")) {
return "redirect:/admin/showStudent";
} else if (subject.hasRole("teacher")) {
return "redirect:/teacher/showCourse";
} else if (subject.hasRole("student")) {
return "redirect:/student/showCourse";
}
return "/login";
}
}
学生管理控制器
@Controller
@RequestMapping(value = "/student")
public class StudentController {
@Resource(name = "courseServiceImpl")
private CourseService courseService;
@Resource(name = "studentServiceImpl")
private StudentService studentService;
@Resource(name = "selectedCourseServiceImpl")
private SelectedCourseService selectedCourseService;
@RequestMapping(value = "/showCourse")
public String stuCourseShow(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 "student/showCourse";
}
// 选课操作
@RequestMapping(value = "/stuSelectedCourse")
public String stuSelectedCourse(int id) throws Exception {
//获取当前用户名
Subject subject = SecurityUtils.getSubject();
String username = (String) subject.getPrincipal();
SelectedCourseCustom selectedCourseCustom = new SelectedCourseCustom();
selectedCourseCustom.setCourseid(id);
selectedCourseCustom.setStudentid(Integer.parseInt(username));
SelectedCourseCustom s = selectedCourseService.findOne(selectedCourseCustom);
if (s == null) {
selectedCourseService.save(selectedCourseCustom);
} else {
throw new CustomException("该门课程你已经选了,不能再选");
}
return "redirect:/student/selectedCourse";
}
// 退课操作
@RequestMapping(value = "/outCourse")
public String outCourse(int id) throws Exception {
Subject subject = SecurityUtils.getSubject();
String username = (String) subject.getPrincipal();
SelectedCourseCustom selectedCourseCustom = new SelectedCourseCustom();
selectedCourseCustom.setCourseid(id);
selectedCourseCustom.setStudentid(Integer.parseInt(username));
selectedCourseService.remove(selectedCourseCustom);
return "redirect:/student/selectedCourse";
}
// 已选课程
@RequestMapping(value = "/selectedCourse")
public String selectedCourse(Model model) throws Exception {
//获取当前用户名
Subject subject = SecurityUtils.getSubject();
StudentCustom studentCustom = studentService.findStudentAndSelectCourseListByName((String) subject.getPrincipal());
List<SelectedCourseCustom> list = studentCustom.getSelectedCourseList();
model.addAttribute("selectedCourseList", list);
return "student/selectCourse";
}
// 已修课程
@RequestMapping(value = "/overCourse")
public String overCourse(Model model) throws Exception {
//获取当前用户名
Subject subject = SecurityUtils.getSubject();
StudentCustom studentCustom = studentService.findStudentAndSelectCourseListByName((String) subject.getPrincipal());
List<SelectedCourseCustom> list = studentCustom.getSelectedCourseList();
model.addAttribute("selectedCourseList", list);
return "student/overCourse";
}
//修改密码
@RequestMapping(value = "/passwordRest")
public String passwordRest() throws Exception {
return "student/passwordRest";
}
}
教师管理控制器
@Controller
@RequestMapping(value = "/teacher")
public class TeacherController {
@Resource(name = "teacherServiceImpl")
private TeacherService teacherService;
@Resource(name = "courseServiceImpl")
private CourseService courseService;
@Resource(name = "selectedCourseServiceImpl")
private SelectedCourseService selectedCourseService;
// 显示我的课程
@RequestMapping(value = "/showCourse")
public String stuCourseShow(Model model) throws Exception {
Subject subject = SecurityUtils.getSubject();
String username = (String) subject.getPrincipal();
List<CourseCustom> list = courseService.findByTeacherID(Integer.parseInt(username));
model.addAttribute("courseList", list);
return "teacher/showCourse";
}
// 显示成绩
@RequestMapping(value = "/gradeCourse")
public String gradeCourse(Integer id, Model model) throws Exception {
if (id == null) {
return "";
}
List<SelectedCourseCustom> list = selectedCourseService.findByCourseID(id);
model.addAttribute("selectedCourseList", list);
return "teacher/showGrade";
}
// 打分
@RequestMapping(value = "/mark", method = {RequestMethod.GET})
public String markUI(SelectedCourseCustom scc, Model model) throws Exception {
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";
}
}
如果也想学习本系统,下面领取。回复:235ssm