IDEA+Java+SSM+Mysql+Layui实现Web学生成绩管理系统【建议收藏】(下)

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS MySQL,高可用系列 2核4GB
简介: IDEA+Java+SSM+Mysql+Layui实现Web学生成绩管理系统【建议收藏】

三、部分代码


AdminController

package com.hhtc.controller;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
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 org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.hhtc.po.Page;
import com.hhtc.po.Student;
import com.hhtc.po.Teacher;
import com.hhtc.service.AdminService;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@Controller
public class AdminController {
  @Autowired
    private AdminService adminService;
  @RequestMapping("/welcome")
  public ModelAndView welcome(Model model) {
    ModelAndView mav = new ModelAndView("admin/welcome");
    return mav;
  }
  //学生
    //学生数据分页
    @RequestMapping(value = "/liststudent",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
    @ResponseBody
    public String liststudent(Page page) {
      List<Student> list=adminService.stumanage();
      page.caculatestart();
      List<Student> list2=adminService.liststudent(page);
      JSONObject jsonobj=new JSONObject();
      jsonobj.put("code", 0);
      jsonobj.put("msg", "成功");
      jsonobj.put("count",list.size());
      JSONArray jsonobj2=new JSONArray();
      JSONObject jsonobj3=new JSONObject();
        for(Student student:list2) {
          jsonobj3.put("id",student.getId());
          jsonobj3.put("username",student.getUsername());
          jsonobj3.put("password",student.getPassword());
          jsonobj3.put("stuclass",student.getStuclass());
          jsonobj3.put("stuname",student.getStuname());
          jsonobj3.put("stuno",student.getStuno());
          jsonobj2.add(jsonobj3);
        }
        jsonobj.put("data", jsonobj2);    
      return jsonobj.toString();
    }
    @RequestMapping("/addstudent")
    public ModelAndView addstu(Student student,Model model) {
      adminService.addStudent(student);
      ModelAndView mav = new ModelAndView("admin/stumanage");
      return mav;
    }
    @RequestMapping("/delstu")
    public ModelAndView delstu(String id,Model model) {
      adminService.delstudnet(id);
      ModelAndView mav = new ModelAndView("admin/stumanage");
      return mav;
    }
    @RequestMapping("/updatestu")
    public ModelAndView updatestu(String id,Student student,Model model) {
      student.setId(Integer.parseInt(id));
      adminService.updatestu(student);
      ModelAndView mav = new ModelAndView("admin/stumanage");
      return mav;
    }
    @RequestMapping(value = "/mohuname",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
    @ResponseBody
    public String mohuname(HttpSession session) {
      @SuppressWarnings("unchecked")
      List<Student> list=(List<Student>) session.getAttribute("list");
      JSONObject jsonobj=new JSONObject();
      jsonobj.put("code", 0);
      jsonobj.put("msg", "成功");
      jsonobj.put("count",list.size());
      JSONArray jsonobj2=new JSONArray();
      JSONObject jsonobj3=new JSONObject();
        for(Student student:list) {
          jsonobj3.put("id",student.getId());
          jsonobj3.put("username",student.getUsername());
          jsonobj3.put("password",student.getPassword());
          jsonobj3.put("stuclass",student.getStuclass());
          jsonobj3.put("stuname",student.getStuname());
          jsonobj3.put("stuno",student.getStuno());
          jsonobj2.add(jsonobj3);
        }
        jsonobj.put("data", jsonobj2);    
      return jsonobj.toString();
    }
  //老师
    @RequestMapping("/addtea")
    public ModelAndView addteacher(Teacher teacher,Model model) {
      adminService.addteacher(teacher);
      ModelAndView mav = new ModelAndView("admin/teamanage");
      return mav;
    }
    @RequestMapping(value = "/teamanage",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
    @ResponseBody
    public String teamanage(Model model) {
      List<Teacher> list=adminService.teamanage();
      JSONObject jsonobj=new JSONObject();
      jsonobj.put("code", 0);
      jsonobj.put("msg", "成功");
      jsonobj.put("count",list.size());
      JSONArray jsonobj2=new JSONArray();
      JSONObject jsonobj3=new JSONObject();
        for(Teacher teacher:list) {
          jsonobj3.put("id",teacher.getId());
          jsonobj3.put("username",teacher.getUsername());
          jsonobj3.put("password",teacher.getPassword());
          jsonobj3.put("teaname",teacher.getTeaname());
          jsonobj2.add(jsonobj3);
        }
        jsonobj.put("data", jsonobj2);    
      return jsonobj.toString();
    }
    @RequestMapping("/deltea")
    public ModelAndView deltea(String id,Model model) {
      adminService.delteacher(id);
      ModelAndView mav = new ModelAndView("admin/teamanage");
      return mav;
    }
    @RequestMapping("/updatetea")
    public ModelAndView updatetea(String id,Teacher teacher,Model model) {
      teacher.setId(Integer.parseInt(id));
      adminService.updatetea(teacher);
      ModelAndView mav = new ModelAndView("admin/teamanage");
      return mav;
    }
    @RequestMapping(value = "/mohunametea",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
    @ResponseBody
    public String mohunametea(HttpSession session) {
      @SuppressWarnings("unchecked")
      List<Teacher> list=(List<Teacher>) session.getAttribute("tealist");
      JSONObject jsonobj=new JSONObject();
      jsonobj.put("code", 0);
      jsonobj.put("msg", "成功");
      jsonobj.put("count",list.size());
      JSONArray jsonobj2=new JSONArray();
      JSONObject jsonobj3=new JSONObject();
        for(Teacher teacher:list) {
          jsonobj3.put("id",teacher.getId());
          jsonobj3.put("username",teacher.getUsername());
          jsonobj3.put("password",teacher.getPassword());
          jsonobj3.put("teaname",teacher.getTeaname());
          jsonobj2.add(jsonobj3);
        }
        jsonobj.put("data", jsonobj2);    
      return jsonobj.toString();
    }
}

HrefController

package com.hhtc.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.hhtc.po.Student;
import com.hhtc.po.Teacher;
import com.hhtc.service.AdminService;
@Controller
public class HrefController {
  @Autowired
  private AdminService adminService;
  @RequestMapping("/index")
  public ModelAndView index(Model model) {
    ModelAndView mav = new ModelAndView("index");
    return mav;
  }
  //学生
  @RequestMapping("/hrefaddstu")
  public ModelAndView addstu(Model model) {
    ModelAndView mav = new ModelAndView("admin/addstu");
    return mav;
  }
  @RequestMapping("/hrefmohuname")
  public ModelAndView hrefmohuname(String stuname,Model model,HttpSession session) {
    List<Student> list=adminService.selectbyname(stuname);
    session.setAttribute("list", list);
    ModelAndView mav = new ModelAndView("admin/mohuname");
    return mav;
  }
  @RequestMapping("/hrefxiustu")
  public String xiustu(String id,Model model) {
    Student student=adminService.selectone(id);
    model.addAttribute("student",student);
    return "admin/updatestu";
  }
  @RequestMapping("/hrefstumanage")
  public ModelAndView hrefstumanage(Model model) {
    ModelAndView mav = new ModelAndView("admin/stumanage");
    return mav;
  }
//老师
  @RequestMapping("/hrefaddtea")
  public ModelAndView hrefaddtea(Model model) {
    ModelAndView mav = new ModelAndView("admin/addtea");
    return mav;
  }
  @RequestMapping("/hrefteamanage")
  public ModelAndView hrefteamanage(Model model) {
    ModelAndView mav = new ModelAndView("admin/teamanage");
    return mav;
  }
  @RequestMapping("/hrefmohunametea")
  public ModelAndView hrefmohunametea(String teaname,Model model,HttpSession session) {
    List<Teacher> list=adminService.selectbynametea(teaname);
    session.setAttribute("tealist",list);
    ModelAndView mav = new ModelAndView("admin/mohuname2");
    return mav;
  }
  @RequestMapping("/hrefxiutea")
  public String hrefxiutea(String id,Model model) {
    Teacher teacher=adminService.selectonetea(id);
    model.addAttribute("teacher",teacher);
    return "admin/updatetea";
  }
}

LoginController

package com.hhtc.controller;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.hhtc.po.Admin;
import com.hhtc.po.Student;
import com.hhtc.po.Teacher;
import com.hhtc.service.LoginService;
@Controller
public class LoginController {
  @Autowired
  private LoginService loginService;  
  @RequestMapping("/login")
  public ModelAndView findCustomerById(String username,String password,String people,Model model,HttpSession session) {
    if("student".equals(people)) {
      Student student=new Student();
      student.setUsername(username);
      student.setPassword(password);
      Student student2=loginService.findStuTeachByUsername(student);
      if(student2!=null) {
        session.setAttribute("student", student2);
        ModelAndView mav = new ModelAndView("/student/indexs");
        return mav;
      }else {
        ModelAndView mav = new ModelAndView("error");
        return mav;
      }
    }else if("teacher".equals(people)){
      Teacher teacher=new Teacher();
      teacher.setUsername(username);
      teacher.setPassword(password);
      Teacher teacher2=loginService.findTeachByUsername(teacher);
      if(teacher2!=null) {
        session.setAttribute("teacher", teacher2);
        ModelAndView mav = new ModelAndView("/teacher/indext");
        return mav;
      }else {
        ModelAndView mav = new ModelAndView("error");
        return mav;
      }
    }else if("manage".equals(people)){
      Admin admin =new Admin();
      admin.setUsername(username);
      admin.setPassword(password);
      if(loginService.findAdminById(admin)!=null) {
        ModelAndView mav = new ModelAndView("/admin/index");
        return mav;
      }else {
        ModelAndView mav = new ModelAndView("error");
        return mav;
      }
    }
    ModelAndView mav = new ModelAndView("error");
    return mav;
  }
  @RequestMapping("/out")
  public ModelAndView out(HttpServletResponse response,HttpSession session,Model model) {
    ModelAndView mav = new ModelAndView("index");
    return mav;
  }
}

StudentController

package com.hhtc.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.hhtc.po.Student;
import com.hhtc.service.GeneraService;
@Controller
public class StudentController {
  @Autowired
  private GeneraService generaService;
  //学生
  @RequestMapping("/hrefstuinfo")
  public ModelAndView hrefstuinfo(Model model) {
    ModelAndView mav = new ModelAndView("student/stuinfo");
    return mav;
  }
  @RequestMapping("/hrefupdatepws")
  public ModelAndView hrefupdatepws(Model model) {
    ModelAndView mav = new ModelAndView("student/updatepws");
    return mav;
  }
  @RequestMapping("/updatepws")
  public ModelAndView updatepws(Student student,Model model) {
    this.generaService.updatepws(student);
    ModelAndView mav = new ModelAndView("success");
    return mav;
  }
}

TeachController

package com.hhtc.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
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 org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.hhtc.po.Page;
import com.hhtc.po.Student;
import com.hhtc.po.Teacher;
import com.hhtc.service.AdminService;
import com.hhtc.service.GeneraService;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@Controller
public class TeachController {
  @Autowired
  private AdminService adminService;
  @Autowired
  private GeneraService generaService;
  @RequestMapping("/hrefaddscore")
  public ModelAndView hrefaddscore(Model model) {
    ModelAndView mav = new ModelAndView("teacher/addscore");
    return mav;
  }
  @RequestMapping("/hrefupdatepw")
  public ModelAndView hrefupdatepw(Model model) {
    ModelAndView mav = new ModelAndView("teacher/updatepw");
    return mav;
  }
  @RequestMapping(value = "/stuscore",method = {RequestMethod.POST, RequestMethod.GET},produces ="application/json;charset=UTF-8")
  @ResponseBody
  public String stuscoree(Page page,Model model) {
    List<Student> list=adminService.stumanage();
    page.caculatestart();
    List<Student> list2=adminService.liststudent(page);
    JSONObject jsonobj=new JSONObject();
    jsonobj.put("code", 0);
    jsonobj.put("msg", "成功");
    jsonobj.put("count",list.size());
    JSONArray jsonobj2=new JSONArray();
    JSONObject jsonobj3=new JSONObject();
      for(Student student:list2) {
        jsonobj3.put("id",student.getId());
        jsonobj3.put("stuno", student.getStuno());
        jsonobj3.put("stuname",student.getStuname());
        jsonobj3.put("stuclass",student.getStuclass());
        jsonobj3.put("score",student.getScore());     
        jsonobj2.add(jsonobj3);
      }
      jsonobj.put("data", jsonobj2);    
    return jsonobj.toString();
  }
  @RequestMapping("/updatepw")
  public ModelAndView updatepw(Teacher teacher,Model model) {
    this.generaService.updatepw(teacher);
    ModelAndView mav = new ModelAndView("success");
    return mav;
  }
  @RequestMapping("/updatescore")
  public ModelAndView updatescore(String id,String score,Model model) {
    Student student=new Student();
    student.setId(Integer.parseInt(id));
    student.setScore(score);
    this.generaService.updatescore(student);
    ModelAndView mav = new ModelAndView("teacher/addscore");
    return mav;
  }
}


四、其他


1.其他系统实现


1.JavaWeb系统系列实现


Java+JSP实现学生图书管理系统


Java+JSP实现学生信息管理系统


Java+JSP实现用户信息管理系统


Java+Servlet+JSP实现航空订票系统


Java+Servlet+JSP实现新闻发布系统


Java+Servlet+JSP实现图书管理系统


Java+Servlet+JSP实现停车场管理系统


Java+Servlet+JSP实现学生信息管理系统


Java+Servlet+JSP实现学生选课管理系统


Java+Servlet+JSP实现学生成绩管理系统-1


Java+Servlet+JSP实现学生成绩管理系统-2


Java+Servlet+JSP实现宠物诊所管理系统


Java+SSM+JSP实现网上考试系统


Java+SSH+JSP实现在线考试系统


Java+SSH+JSP实现医院在线挂号系统


Java+Springboot+Mybatis+Bootstrap+Maven实现网上商城系统


2.JavaSwing系统系列实现


Java+Swing实现斗地主游戏


Java+Swing实现图书管理系统


Java+Swing实现医院管理系统


Java+Swing实现考试管理系统


Java+Swing实现仓库管理系统-1


Java+Swing实现仓库管理系统-2


Java+Swing实现自助取款机系统


Java+Swing实现通讯录管理系统


Java+Swing实现停车场管理系统


Java+Swing实现学生信息管理系统


Java+Swing实现学生宿舍管理系统


Java+Swing实现学生选课管理系统


Java+Swing实现学生成绩管理系统


Java+Swing实现学校教材管理系统


Java+Swing实现学校教务管理系统


Java+Swing实现企业人事管理系统


Java+Swing实现电子相册管理系统


Java+Swing实现超市管理系统-TXT存储数据


Java+Swing实现自助取款机系统-TXT存储数据


Java+Swing实现宠物商店管理系统-TXT存储数据


相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
4月前
|
关系型数据库 MySQL Java
【IDEA】java后台操作mysql数据库驱动常见错误解决方案
【IDEA】java后台操作mysql数据库驱动常见错误解决方案
165 0
|
4月前
|
SQL 存储 关系型数据库
MySQL 与 IntelliJ IDEA 同时兼容的注释
MySQL 与 IntelliJ IDEA 同时兼容的注释
85 2
|
4月前
|
数据可视化 关系型数据库 MySQL
【IDEA】配置mysql环境并创建mysql数据库
【IDEA】配置mysql环境并创建mysql数据库
469 0
|
6月前
|
关系型数据库 MySQL Linux
【Azure 应用服务】在创建Web App Service的时候,选Linux系统后无法使用Mysql in App
【Azure 应用服务】在创建Web App Service的时候,选Linux系统后无法使用Mysql in App
【Azure 应用服务】在创建Web App Service的时候,选Linux系统后无法使用Mysql in App
|
6月前
|
前端开发 数据挖掘 关系型数据库
基于Python的哔哩哔哩数据分析系统设计实现过程,技术使用flask、MySQL、echarts,前端使用Layui
本文介绍了一个基于Python的哔哩哔哩数据分析系统,该系统使用Flask框架、MySQL数据库、echarts数据可视化技术和Layui前端框架,旨在提取和分析哔哩哔哩用户行为数据,为平台运营和内容生产提供科学依据。
406 9
|
6月前
|
数据采集 数据可视化 关系型数据库
【优秀python web设计】基于Python flask的猫眼电影可视化系统,可视化用echart,前端Layui,数据库用MySQL,包括爬虫
本文介绍了一个基于Python Flask框架、MySQL数据库和Layui前端框架的猫眼电影数据采集分析与可视化系统,该系统通过爬虫技术采集电影数据,利用数据分析库进行处理,并使用Echart进行数据的可视化展示,以提供全面、准确的电影市场分析结果。
190 4
|
7月前
|
关系型数据库 MySQL Go
go项目实现mysql接入以及web api
go项目实现mysql接入以及web api
57 0
|
7月前
|
关系型数据库 MySQL 数据库
MybatisPlus添加数据数据库没有数据,数据消失,使用Navicate看不到数据,Navicate中Mysql的数据与idea的数据不一定同步,Navicate与idea的数据库同步,其实有分页
MybatisPlus添加数据数据库没有数据,数据消失,使用Navicate看不到数据,Navicate中Mysql的数据与idea的数据不一定同步,Navicate与idea的数据库同步,其实有分页
|
6天前
|
存储 Java 关系型数据库
ssm026校园美食交流系统(文档+源码)_kaic
本文介绍了基于Java语言和MySQL数据库的校园美食交流系统的设计与实现。该系统采用B/S架构和SSM框架,旨在提高校园美食信息管理的效率与便捷性。主要内容包括:系统的开发背景、目的及内容;对Java技术、MySQL数据库、B/S结构和SSM框架的介绍;系统分析部分涵盖可行性分析、性能分析和功能需求分析;最后详细描述了系统各功能模块的具体实现,如登录、管理员功能(美食分类管理、用户管理等)和前台首页功能。通过此系统,管理员可以高效管理美食信息,用户也能方便地获取和分享美食资讯,从而提升校园美食交流的管理水平和用户体验。
|
6月前
|
Java 数据库连接 Maven
手把手教你如何搭建SSM框架、图书商城系统案例
这篇文章是关于如何搭建SSM框架以及实现一个图书商城系统的详细教程,包括了项目的配置文件整合、依赖管理、项目结构和运行效果展示,并提供了GitHub源码链接。
手把手教你如何搭建SSM框架、图书商城系统案例

热门文章

最新文章

  • 1
    打造高效的Web Scraper:Python与Selenium的完美结合
    13
  • 2
    Burp Suite Professional 2025.2 (macOS, Linux, Windows) - Web 应用安全、测试和扫描
    26
  • 3
    AppSpider Pro 7.5.015 for Windows - Web 应用程序安全测试
    20
  • 4
    【02】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-2月12日优雅草简化Centos stream8安装zabbix7教程-本搭建教程非docker搭建教程-优雅草solution
    54
  • 5
    部署使用 CHAT-NEXT-WEB 基于 Deepseek
    342
  • 6
    【2025优雅草开源计划进行中01】-针对web前端开发初学者使用-优雅草科技官网-纯静态页面html+css+JavaScript可直接下载使用-开源-首页为优雅草吴银满工程师原创-优雅草卓伊凡发布
    26
  • 7
    java spring 项目若依框架启动失败,启动不了服务提示端口8080占用escription: Web server failed to start. Port 8080 was already in use. Action: Identify and stop the process that’s listening on port 8080 or configure this application to listen on another port-优雅草卓伊凡解决方案
    40
  • 8
    零基础构建开源项目OpenIM桌面应用和pc web- Electron篇
    28
  • 9
    【01】客户端服务端C语言-go语言-web端PHP语言整合内容发布-优雅草网络设备监控系统-硬件设备实时监控系统运营版发布-本产品基于企业级开源项目Zabbix深度二开-分步骤实现预计10篇合集-自营版
    22
  • 10
    FastAPI与Selenium:打造高效的Web数据抓取服务 —— 采集Pixabay中的图片及相关信息
    55