栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

SSM的教务管理系统(免费源码获取)

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SSM的教务管理系统(免费源码获取)

ssm-教务系统

介绍

采用了spring mvc,spring,mybatis框架,前端用到js,html,主要功能包括:课程管理,学生管理,教师管理,账号密码重置等功能

安装教程

  1. 把项目放到idea

  2. 注意把连接的数据库信息修改成自己的

  3. 配置tomcat

  4. 导入依赖,如果有的爆红导不进去可以选择换个maven版本试试

package com.system.controller;
​
import com.system.exception.CustomException;
import com.system.po.*;
import com.system.service.*;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
​
import javax.annotation.Resource;
import java.util.List;
​
​
@Controller
@RequestMapping("/admin")
public class AdminController {
​
    @Resource
    private StudentService studentService;
​
    @Resource
    private TeacherService teacherService;
​
    @Resource
    private CourseService courseService;
​
    @Resource
    private CollegeService collegeService;
​
    @Resource
    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";
    }
​

    // 本账户密码重置
    @RequestMapping("/passwordRest")
    public String passwordRestUI() throws Exception {
        return "admin/passwordRest";
    }

​
}

 教务管理系统下载链接https://gitee.com/wuyanzua/blog-applet

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/998728.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号