开发环境
JDK 1.8
MySQL 5.7
MAVEN 3.8.1
Tomcat 9.0.45
引用 jar 包:
junit、druid、dbutils、dom4j、mysql-connector、servlet、fastjson、jackson-databind、jackson-core、jackson-annotations、lombok、aspectjweaver、spring-webmvc、spring-core、jwt
演示
登录页面
学生页面
教师页面
管理员页面
系统概述
学生成绩信息管理系统涉及到学生、教师、系统管理员、班级、学生成绩、课程。
- 管理员通过账号、密码登录,管理员进入系统可以对课程,系部,教师,学生,专业进行添加、查看。
- 教师通过教工号和密码登录,教师进入系统可以查看自己教的所有课程,以及对选该课程的学生成绩进行修改。
- 学生通过学号和密码进行登录,学生进入系统可以查看自己学习课程的信息以及成绩。
系统功能分析
Student
- 登录
- 查看成绩
Teacher
- 登录查看课程
- 查看学生成绩
- 录入成绩
Administrator
- 登录
- 查看系部
- 查看系部下的专业
- 查看专业下的班级
- 查看班级下的学生
- 新建系部
- 新建系部下的专业
- 新建专业下的班级
- 新建班级下的学生
- 新建课程
项目实现
数据库
创建数据库
CREATE DATABASE sams;
创建 administrators 数据表
CREATETABLE `administrators` ( `id` int(11)NOTNULL AUTO_INCREMENT, `name` varchar(40) DEFAULT NULL, `account` varchar(40) DEFAULT NULL, `password` varchar(40) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `UNIQUE` (`account`) COMMENT '账号唯一') ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
创建 calsses 表
CREATETABLE `classes` ( `id` int(11)NOTNULL AUTO_INCREMENT, `name` varchar(40) DEFAULT NULL, `graduationyear` varchar(40) DEFAULT NULL, `majorid` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `majorid` (`majorid`), CONSTRAINT `classes_ibfk_1` FOREIGN KEY (`majorid`) REFERENCES `majors` (`id`)) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;
创建 courses 表
CREATETABLE `courses` ( `id` int(11)NOTNULL AUTO_INCREMENT, `name` varchar(40) DEFAULT NULL, `teacherid` int(11) DEFAULT NULL, `beginyear` timestampNULL DEFAULT NULL, `endyear` timestampNULL DEFAULT NULL, PRIMARY KEY (`id`), KEY `teacherid` (`teacherid`), CONSTRAINT `courses_ibfk_1` FOREIGN KEY (`teacherid`) REFERENCES `teachers` (`id`)) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8;
创建 majors 表
CREATETABLE `majors` ( `id` int(11)NOTNULL AUTO_INCREMENT, `name` varchar(100) DEFAULT NULL, `sdeptid` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `sdeptid` (`sdeptid`), CONSTRAINT `majors_ibfk_1` FOREIGN KEY (`sdeptid`) REFERENCES `sdepts` (`id`)) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
创建 scores 表
CREATETABLE `scores` ( `id` int(11)NOTNULL AUTO_INCREMENT, `studentid` int(11) DEFAULT NULL, `courseid` int(11) DEFAULT NULL, `grade` double DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `studentid` (`studentid`,`courseid`), KEY `courseid` (`courseid`), CONSTRAINT `scores_ibfk_1` FOREIGN KEY (`studentid`) REFERENCES `students` (`id`), CONSTRAINT `scores_ibfk_2` FOREIGN KEY (`courseid`) REFERENCES `courses` (`id`)) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8;
创建 sdepts 表
CREATETABLE `sdepts` ( `id` int(11)NOTNULL AUTO_INCREMENT, `name` varchar(40) DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8;
创建 students 表
CREATETABLE `students` ( `id` int(11)NOTNULL AUTO_INCREMENT, `name` varchar(40) DEFAULT NULL, `password` varchar(40) DEFAULT NULL, `sdeptid` int(11) DEFAULT NULL, `majorid` int(11) DEFAULT NULL, `classid` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `sdeptid` (`sdeptid`), KEY `majorid` (`majorid`), KEY `classid` (`classid`), CONSTRAINT `students_ibfk_1` FOREIGN KEY (`sdeptid`) REFERENCES `sdepts` (`id`), CONSTRAINT `students_ibfk_2` FOREIGN KEY (`majorid`) REFERENCES `majors` (`id`), CONSTRAINT `students_ibfk_3` FOREIGN KEY (`classid`) REFERENCES `classes` (`id`)) ENGINE=InnoDB AUTO_INCREMENT=2020020223 DEFAULT CHARSET=utf8;
创建 teachers 表
CREATETABLE `teachers` ( `id` int(11)NOTNULL AUTO_INCREMENT, `name` varchar(40) DEFAULT NULL, `password` varchar(100) DEFAULT NULL, `sdeptid` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `sdeptid` (`sdeptid`), CONSTRAINT `teachers_ibfk_1` FOREIGN KEY (`sdeptid`) REFERENCES `sdepts` (`id`)) ENGINE=InnoDB AUTO_INCREMENT=2020221 DEFAULT CHARSET=utf8;
创建 tokens 表
CREATETABLE `tokens` ( `token` varchar(120)NOTNULL, `overtime` timestampNULL DEFAULT NULL, `adminId` int(11) DEFAULT NULL, `studentId` int(11) DEFAULT NULL, `teacherId` int(11) DEFAULT NULL, PRIMARY KEY (`token`), KEY `adminId` (`adminId`), KEY `studentId` (`studentId`), KEY `teacherId` (`teacherId`), CONSTRAINT `tokens_ibfk_1` FOREIGN KEY (`adminId`) REFERENCES `administrators` (`id`), CONSTRAINT `tokens_ibfk_2` FOREIGN KEY (`studentId`) REFERENCES `students` (`id`), CONSTRAINT `tokens_ibfk_3` FOREIGN KEY (`teacherId`) REFERENCES `teachers` (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;
配置文件
pom.xml 配置
<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.xxxx</groupId><artifactId>sams</artifactId><version>1.0-SNAPSHOT</version><packaging>war</packaging><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target></properties><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version><scope>test</scope></dependency><dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.1.10</version></dependency><dependency><groupId>commons-dbutils</groupId><artifactId>commons-dbutils</artifactId><version>1.7</version></dependency><dependency><groupId>dom4j</groupId><artifactId>dom4j</artifactId><version>1.6.1</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.47</version></dependency><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>4.0.1</version></dependency><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.2.75</version></dependency><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId><version>2.9.8</version></dependency><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-core</artifactId><version>2.9.8</version></dependency><dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-annotations</artifactId><version>2.9.8</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-core</artifactId><version>5.2.6.RELEASE</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId><version>5.2.6.RELEASE</version></dependency><dependency><groupId>org.aspectj</groupId><artifactId>aspectjweaver</artifactId><version>1.9.2</version></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.12</version></dependency><dependency><groupId>com.auth0</groupId><artifactId>java-jwt</artifactId><version>3.8.2</version></dependency></dependencies><!--静态资源导出--><build><resources><resource><directory>src/main/java</directory><includes><include>**/*.properties</include><include>**/*.xml</include></includes><filtering>false</filtering></resource><resource><directory>src/main/resources</directory><includes><include>**/*.properties</include><include>**/*.xml</include></includes><filtering>false</filtering></resource></resources></build></project>
web.xml 配置
<web-appxmlns="http://xmlns.jcp.org/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaeehttp://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"version="4.0"><!--配置前端控制器--><servlet><servlet-name>dispatcherServlet</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><init-param><param-name>contextConfigLocation</param-name><param-value>classpath:SpringMvc.xml</param-value></init-param><load-on-startup>1</load-on-startup></servlet><servlet-mapping><servlet-name>dispatcherServlet</servlet-name><url-pattern>/</url-pattern></servlet-mapping><!-- 此过滤器会进行:request.setCharactorEncoding("utf-8"); --><filter><filter-name>encoding</filter-name><filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><init-param><param-name>encoding</param-name><param-value>utf-8</param-value></init-param></filter><filter-mapping><filter-name>encoding</filter-name><url-pattern>/*</url-pattern></filter-mapping><!--欢迎页面--><welcome-file-list><welcome-file>/WEB-INF/jsp/index.html</welcome-file></welcome-file-list><error-page><location>/WEB-INF/jsp/index.html</location></error-page></web-app>
spring-mvc.xml 配置
<beansxmlns="http://www.springframework.org/schema/beans"xmlns:mvc="http://www.springframework.org/schema/mvc"xmlns:context="http://www.springframework.org/schema/context"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsd"><mvc:annotation-driven/><context:component-scanbase-package="controller"/><mvc:default-servlet-handler/><!-- 开启SpringMVC框架注解的支持 --><beanclass="org.springframework.web.servlet.view.InternalResourceViewResolver"id="internalResourceViewResolver"><propertyname="prefix"value="/WEB-INF/jsp/"/><propertyname="suffix"value=".html"/></bean><mvc:annotation-driven><mvc:message-convertersregister-defaults="true"><!-- 启动Spring MVC的注解功能,完成请求和注解POJO的映射 注解请求映射默认是ISO-88859-1,避免乱码这里设置为UTF-8 --><beanclass="org.springframework.http.converter.StringHttpMessageConverter"><propertyname="supportedMediaTypes"value="text/html;charset=UTF-8"/></bean><!-- 启动JSON格式的配置,自动将格式转换成JSON格式,不需要其他类 --><beanid="jacksonMessageConverter"class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"><propertyname="supportedMediaTypes"value="application/json;charset=UTF-8"/></bean></mvc:message-converters></mvc:annotation-driven><!-- <mvc:resources mapping="/html/**" location="/pages/" />--></beans>
jdbc.properties 配置
url=jdbc:mysql://localhost:3306/sams?useUnicode=true&characterEncoding=utf-8 username=root password=123456 driver=com.mysql.jdbc.Driver initialSize=10 maxActive=30
项目结构
目录 | |
controller | 控制层,负责处理业务模块流程的控制器 |
service | 业务逻辑层,负责处理业务模块 |
dao | 数据持久层, 负责与数据库进行交互 |
pojo | 存放 JavaBean 类 |
utils | 工具类,提供一些工具 |
resources | 存放资源文件 |
项目下载地址:javaWeb项目学生成绩信息管理系统
Gitee 项目开源地址:Student Management System