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<StudentCustom> 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<College> 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<College> 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<StudentCustom> 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

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值