功能介绍
该项目是一个简单的教务查询系统,分别授予管理员,教师,学生不同的权限,达到基本的数据查询与修改操作。
管理员主要功能:
课程管理、学生管理、教师管理;
教师主要功能:
查看我教授的课程列表、查看学生成绩列表、给学生打分;
学生主要功能:
查看所有课程列表、选课、查看所修课程等;
环境需要
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版本;
使用技术
IOC容器:Spring
Web框架:SpringMVC ORM框架:Mybatis 安全框架:Shiro
数据源:C3P0日志:log4j
前端框架:Bootstrap
使用说明
1.使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,下载所需jar包;
2.使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
3.将项目中mysql.properties配置文件中的数据库配置改为自己的配置
4.配置tomcat,然后运行项目,输入localhost:8080/xxx 登录
运行截图






相关代码
@Controller
@RequestMapping("/admin")
public class AdminController {
@Resource(name ="studentServiceImpl")
private StudentService studentService;
@Resource(name ="teacherServiceImpl")
private TeacherService teacherService;
@Resource(name ="courseServiceImpl")
private CourseService courseService;
@Resource(name ="collegeServiceImpl")
private CollegeService collegeService;
@Resource(name ="userloginServiceImpl")
private UserloginService userloginService;
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<学生操作>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
// 学生信息显示
@RequestMapping("/showStudent")
public String showStudent(Model model, Integer page)throws Exception {
List list =null;
//页码对象
PagingVO pagingVO =new PagingVO();
//设置总页数
pagingVO.setTotalCount(studentService.getCountStudent());
if (page ==null || page ==0) {
pagingVO.setToPageNo(1);
list = studentService.findByPaging(1);
}else {
pagingVO.setToPageNo(page);
list = studentService.findByPaging(page);
}
model.addAttribute("studentList", list);
model.addAttribute("pagingVO", pagingVO);
return "admin/showStudent";
}
// 添加学生信息页面显示
@RequestMapping(value ="/addStudent", method = {RequestMethod.GET})
public String addStudentUI(Model model)throws Exception {
List list = collegeService.finAll();
model.addAttribute("collegeList", list);
return "admin/addStudent";
}
// 添加学生信息操作
@RequestMapping(value ="/addStudent", method = {RequestMethod.POST})
public String addStudent(StudentCustom studentCustom, Model model)throws Exception {
Boolean result = studentService.save(studentCustom);
if (!result) {
model.addAttribute("message","学号重复");
return "error";
}
//添加成功后,也添加到登录表
Userlogin userlogin =new Userlogin();
userlogin.setUsername(studentCustom.getUserid().toString());
userlogin.setPassword("123");
userlogin.setRole(2);
userloginService.save(userlogin);
//重定向
return "redirect:/admin/showStudent";
}
// 修改学生信息页面显示
@RequestMapping(value ="/editStudent", method = {RequestMethod.GET})
public String editStudentUI(Integer id, Model model)throws Exception {
if (id ==null) {
//加入没有带学生id就进来的话就返回学生显示页面
return "redirect:/admin/showStudent";
}
StudentCustom studentCustom = studentService.findById(id);
if (studentCustom ==null) {
throw new CustomException("未找到该名学生");
}
List list = collegeService.finAll();
model.addAttribute("collegeList", list);
model.addAttribute("student", studentCustom);
return "admin/editStudent";
}
// 修改学生信息处理
@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} )
private String removeStudent(Integer id)throws Exception {
if (id ==null) {
//加入没有带学生id就进来的话就返回学生显示页面
return "admin/showStudent";
}
studentService.removeById(id);
userloginService.removeByName(id.toString());
return "redirect:/admin/showStudent";
}
// 搜索学生
@RequestMapping(value ="selectStudent", method = {RequestMethod.POST})
private String selectStudent(String findByName, Model model)throws Exception {
List list = studentService.findByName(findByName);
model.addAttribute("studentList", list);
return "admin/showStudent";
}
网友评论