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

本文涉及的产品
RDS MySQL DuckDB 分析主实例,集群系列 4核8GB
RDS AI 助手,专业版
简介: 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存储数据


相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。 &nbsp; 相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/mysql&nbsp;
相关文章
|
SQL 监控 安全
Java Web应用的安全防护与攻防策略
Java Web应用的安全防护与攻防策略
|
5月前
|
安全 Java API
Java Web 在线商城项目最新技术实操指南帮助开发者高效完成商城项目开发
本项目基于Spring Boot 3.2与Vue 3构建现代化在线商城,涵盖技术选型、核心功能实现、安全控制与容器化部署,助开发者掌握最新Java Web全栈开发实践。
546 1
|
5月前
|
存储 前端开发 Java
【JAVA】Java 项目实战之 Java Web 在线商城项目开发实战指南
本文介绍基于Java Web的在线商城技术方案与实现,涵盖三层架构设计、MySQL数据库建模及核心功能开发。通过Spring MVC + MyBatis + Thymeleaf实现商品展示、购物车等模块,提供完整代码示例,助力掌握Java Web项目实战技能。(238字)
577 0
|
6月前
|
前端开发 Java 数据库
Java 项目实战从入门到精通 :Java Web 在线商城项目开发指南
本文介绍了一个基于Java Web的在线商城项目,涵盖技术方案与应用实例。项目采用Spring、Spring MVC和MyBatis框架,结合MySQL数据库,实现商品展示、购物车、用户注册登录等核心功能。通过Spring Boot快速搭建项目结构,使用JPA进行数据持久化,并通过Thymeleaf模板展示页面。项目结构清晰,适合Java Web初学者学习与拓展。
468 1
|
存储 Java
【编程基础知识】 分析学生成绩:用Java二维数组存储与输出
本文介绍如何使用Java二维数组存储和处理多个学生的各科成绩,包括成绩的输入、存储及格式化输出,适合初学者实践Java基础知识。
329 1
|
Java 关系型数据库 MySQL
基于Java的学生成绩管理系统/学生信息管理系统
基于Java的学生成绩管理系统/学生信息管理系统
365 2
|
关系型数据库 MySQL Linux
【Azure 应用服务】在创建Web App Service的时候,选Linux系统后无法使用Mysql in App
【Azure 应用服务】在创建Web App Service的时候,选Linux系统后无法使用Mysql in App
132 0
【Azure 应用服务】在创建Web App Service的时候,选Linux系统后无法使用Mysql in App
|
数据采集 数据可视化 关系型数据库
【优秀python web设计】基于Python flask的猫眼电影可视化系统,可视化用echart,前端Layui,数据库用MySQL,包括爬虫
本文介绍了一个基于Python Flask框架、MySQL数据库和Layui前端框架的猫眼电影数据采集分析与可视化系统,该系统通过爬虫技术采集电影数据,利用数据分析库进行处理,并使用Echart进行数据的可视化展示,以提供全面、准确的电影市场分析结果。
709 4
|
安全 前端开发 Java
Web端系统开发解决跨域问题——以Java SpringBoot框架配置Cors为例
在Web安全上下文中,源(Origin)是指一个URL的协议、域名和端口号的组合。这三个部分共同定义了资源的来源,浏览器会根据这些信息来判断两个资源是否属于同一源。例如,https://www.example.com:443和http://www.example.com虽然域名相同,但由于协议和端口号不同,它们被视为不同的源。同源(Same-Origin)是指两个URL的协议、域名和端口号完全相同。只有当这些条件都满足时,浏览器才认为这两个资源来自同一源,从而允许它们之间的交互操作。
477 0
Web端系统开发解决跨域问题——以Java SpringBoot框架配置Cors为例
|
消息中间件 Java 微服务
构建可扩展的Java Web应用架构
构建可扩展的Java Web应用架构

推荐镜像

更多