👉文末查看项目功能视频演示+获取源码+sql脚本+视频导入教程视频
1 、功能描述
基于SSM的学生管理系统2拥有三种角色
- 管理员:学生管理、教师管理、课程管理、个人信息管理等
- 教师:添加课程、录入成绩、查看选课名单和结课、个人信息等
- 学生:选课、退课、查看已修课程、个人信息等
1.1 背景描述
学生管理系统是一款功能强大的软件应用,专为学校和教育机构设计,以简化学生信息的日常管理。通过此系统,用户可以轻松录入、修改、查询和删除学生信息,包括基本信息、成绩、课程和考勤等。此外,系统还具备数据统计和分析功能,帮助教育机构更全面地掌握学生的学习情况。通过使用学生管理系统,学校不仅可以提高管理效率,减少工作负担,还能确保学生信息的准确性和安全性,为教育环境的优化提供有力支持。
2、项目技术
后端框架:SSM(Spring、SpringMVC、Mybatis)
前端技术:Bootstrap、jsp、css、JavaScript、JQuery
2.1 SSM
SSM(Spring+SpringMVC+MyBatis)是目前比较主流的Java EE企业级框架,适用于搭建各种大型的企业级应用系统。其中,Spring就像是整个项目中的粘合剂,负责装配bean并管理其生命周期,实现控制反转(IoC)的功能。SpringMVC负责拦截用户请求,通过DispatcherServlet将请求匹配到相应的Controller并执行。而MyBatis则是对JDBC的封装,让数据库底层操作变得透明,通过配置文件关联到各实体类的Mapper文件,实现了SQL语句映射。
2.2 mysql
MySQL是一款Relational Database Management System,直译过来的意思就是关系型数据库管理系统,MySQL有着它独特的特点,这些特点使他成为目前最流行的RDBMS之一,MySQL想比与其他数据库如ORACLE、DB2等,它属于一款体积小、速度快的数据库,重点是它符合本次毕业设计的真实租赁环境,拥有成本低,开发源码这些特点,这也是选择它的主要原因。
3、开发环境
- JAVA版本:JDK1.8
- IDE类型:IDEA、Eclipse都可运行
- tomcat版本:Tomcat 7-10版本均可
- 数据库类型:MySql(5.x和8.x版本都可)
- maven版本:无限制
- 硬件环境:Windows 或者 Mac OS
4、功能截图+视频演示+文档目录
4.1 登录
4.2 学生模块
4.3 教师模块
4.4 管理员模块
5 、核心代码实现
5.1 配置代码
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-4.1.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-4.1.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"><context:annotation-config /><context:component-scan base-package="net.fuzui.StudentInfo.service" /><!-- druid连接池 --><bean id="abstractDataSource" abstract="true" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"><property name="driverClassName" value="com.mysql.cj.jdbc.Driver" /><!-- 配置初始化大小、最大、最小 --><property name="initialSize" value="1" /><property name="minIdle" value="10" /><property name="maxActive" value="10" /><!-- 配置获取连接等待超时的实际 --><property name="maxWait" value="60000" /></bean><!-- 配置写库 继承abstractDataSource--><bean id="dataSourceWrite" parent="abstractDataSource"><!-- 基本url、username、password --><property name="url" value="jdbc:mysql://127.0.0.1:3306/selc?serverTimezone=UTC&allowPublicKeyRetrieval=true&characterEncoding=utf-8&useSSL=false&autoReconnect=true&allowMultiQueries=true" /><property name="username" value="root" /><property name="password" value="root" /></bean><!-- 配置读库 继承abstractDataSource--><bean id="dataSourceRead" parent="abstractDataSource"><!-- 基本 url、username、password --><property name="url" value="jdbc:mysql://127.0.0.1:3306/selc?serverTimezone=UTC&allowPublicKeyRetrieval=true&characterEncoding=utf-8&useSSL=false&autoReconnect=true&allowMultiQueries=true" /><property name="username" value="root" /><property name="password" value="root" /></bean><!-- 动态数据源 --><bean id="dataSource" class="net.fuzui.StudentInfo.mysql_rws.DynamicDataSource"><property name="writeDataSource" ref="dataSourceWrite" /><property name="readDataSource" ref="dataSourceRead" /></bean><!--<tx:annotation-driven transaction-manager="transactionManager" />--><!-- sqlSessionFactory --><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><!-- 实例化sqlSessionFaction时用到上面的数据源以及sql映射文件 --><property name="dataSource" ref="dataSource" /><!-- 引入mybatis配置文件 --><property name="configLocation" value="classpath:config/mybatis/mybatis-config.xml" /><!-- mapper配置文件 --><property name="mapperLocations" value="classpath:mapper/*.xml" /><!-- pojo --><property name="typeAliasesPackage" value="net.fuzui.StudentInfo.pojo" /><!-- plugin --><property name="plugins"><array><bean class="net.fuzui.StudentInfo.mysql_rws.DynamicPlugin" /></array></property> </bean><!-- 配置扫描器 --><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="net.fuzui.StudentInfo.mapper"></property><property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property></bean></beans>
5.2 登录核心代码
package net.fuzui.StudentInfo.handler;import net.fuzui.StudentInfo.pojo.Student;
import net.fuzui.StudentInfo.pojo.Teacher;
import net.fuzui.StudentInfo.service.AdminService;
import net.fuzui.StudentInfo.service.CoursePlanService;
import net.fuzui.StudentInfo.service.CourseService;
import net.fuzui.StudentInfo.service.SelectCourseService;
import net.fuzui.StudentInfo.service.StudentService;
import net.fuzui.StudentInfo.service.TeacherService;
import net.fuzui.StudentInfo.service.impl.AdminServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;import java.util.ArrayList;
import java.util.List;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;/*** @ProjectName: StudentInfo* @Package: net.fuzui.StudentInfo.handler* @ClassName: AdminHandler* @Description: admin的handler层(servlet)* @Author: 王泽* @CreateDate: 2019-04-10 22:50* @UpdateUser: 王泽* @UpdateDate: 2019-04-10 22:50* @UpdateRemark: 新建* @Version: 1.0*/@Controller
@RequestMapping("/LoginHandler")
public class LoginHandler {@AutowiredAdminService adminServiceImpl;@AutowiredStudentService studentService;@AutowiredTeacherService teacherService;//管理员登录@RequestMapping("/adminlogin")public String loginStudent(@RequestParam("aname") String aname, @RequestParam("apassword") String apassword,Model model, HttpSession httpSession) {String n = null;n = adminServiceImpl.queryByNamePwd(aname,apassword);if (n != null && !"".equals(n)) {httpSession.setAttribute("aname", aname);return "admin/adminFace";} else {return "login";}}// 管理员退出登录@RequestMapping("/adminlogout")public ModelAndView adminLogout(HttpSession httpSession) {httpSession.removeAttribute("aname");httpSession.removeAttribute("couList");return new ModelAndView(new RedirectView("/StudentInfo/index.jsp"));}// 学生登录@RequestMapping("/studentlogin")public ModelAndView loginStudent(@RequestParam("sid") String sid, @RequestParam("spassword") String spassword,Model model, HttpSession httpSession, HttpServletRequest httpRequest) {Student student = new Student();student = studentService.getByStuSid(sid);if (studentService.queryByNamePwd(sid, spassword) != null) {httpSession.setAttribute("sid", sid);httpSession.setAttribute("sname", student.getSname());return new ModelAndView(new RedirectView("../student/studentFace.jsp"));} else {httpRequest.setAttribute("msg","账号或密码不正确,登录失败!");return new ModelAndView(new RedirectView("../fail.jsp"));}}// 学生退出登录@RequestMapping("/studentlogout")public ModelAndView studentLogout(HttpSession httpSession) {httpSession.removeAttribute("sid");httpSession.removeAttribute("sname");httpSession.removeAttribute("courseList");httpSession.removeAttribute("ssrList");httpSession.removeAttribute("sesList");return new ModelAndView(new RedirectView("/StudentInfo/index.jsp"));}// 教师登录@RequestMapping("/teacherlogin")public ModelAndView loginTeacher(@RequestParam("tid") String tid, @RequestParam("tpassword") String tpassword,Model model, HttpSession httpSession) {if (teacherService.queryByNamePwd(tid, tpassword) != null) {Teacher teacher = new Teacher();teacher = teacherService.getByTeaTid(tid);// model.addAttribute("tid", tid);httpSession.setAttribute("tid", tid);httpSession.setAttribute("tname", teacher.getTname());// httpSession.setAttribute("teachername", teacher.getTname());return new ModelAndView(new RedirectView("../teacher/teacherFace.jsp"));} else {return new ModelAndView(new RedirectView("../fail.jsp"));}}// 教师退出登录@RequestMapping("/teacherlogout")public ModelAndView teacherLogout(HttpSession httpSession) {httpSession.removeAttribute("tid");httpSession.removeAttribute("tname");httpSession.removeAttribute("couList");httpSession.removeAttribute("sesList");httpSession.removeAttribute("lookList");return new ModelAndView(new RedirectView("/StudentInfo/index.jsp"));}
}
6 、功能视频演示
基于SSM的学生管理系统