Basic version of student information management system based on java eclipse+jsp+mysql+servlet+Spring

Background of the project

The management of student information files is very important for school administrators. Student information is a very important data resource for colleges and universities and an indispensable part of an educational unit. Especially in recent years, the adjustment of national policies and the large-scale expansion of enrollment in my country's colleges and universities have brought a lot of impact to the teaching management, student management, logistics management and other aspects of colleges and universities. It contains a large amount of data, involves a wide range of personnel, and needs to be updated in time, so it is more complicated and difficult to rely solely on manual management. Moreover, the traditional manual management method is neither easy to standardize nor efficient. There are still a considerable number of student file management in colleges and universities still on the basis of paper media, especially the management of student files in primary and secondary schools is even more backward, such a management mechanism can no longer meet the requirements of the development of the times, and its management methods will be wasteful Many human and material resources. With the continuous improvement of science and technology, computer science and technology are becoming more and more mature, and the popularization of computer applications has entered all fields of human social life and played an increasingly important role. This traditional manual management mode is bound to be replaced by computer-based information management methods.

feature design

Main function: user login with different roles (teacher, student, administrator)

System Homepage Introduction

Student management: add students, view student list information, view student information

Teacher management: add teachers, view teacher list information, view teacher information

Grade Management: View Grade Information, Modify Grades

Personal Center: Modify personal information, avatar, etc., log out

role conception

It has three roles of administrator, teacher and student, each role corresponds to different menu permissions

Main technique

The technologies used are relatively basic, easy to learn and easy to understand Java jsp+mysql+servlet+jdbc+jquery+html+css, etc.

Specific function realization

Log in:

Login according to different account roles

front page:

The home page mainly uses css and other simple layouts, the left side is the menu bar, the middle is the system introduction, the upper right corner is the personal center and account information and logout.

Student Administration:

Add students

Student List:

Administrators have edit and delete permissions, and teachers have edit permissions. Students can only view information.

Teacher management:

Add teacher information

View teacher list information:

Grade Management:

View student grade information

Personal Center:

Personal center randomly made an alert pop-up window

Part of the code implementation:

Log in to the front end:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>学生信息管理系统</title>
<script src="js/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="js/login.js" type="text/javascript"></script>
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>
<body>
  <center>
    <div class="login">
      <div class="login_head">
        <h3>登录</h3>
      </div>
      <div class="login_window">
        <div>
          <label>账号:</label> <br> <input type="text" name="ope_name"
            id="ope_name">
        </div>
        <div>
          <label>密码:</label> <br> <input type="password" name="ope_pwd"
            id="ope_pwd">
        </div>
        <input
          style="width:60px; float:right; margin-top:10px;margin-right:20px;"
          type="button" value="登录" οnclick="login()">
      </div>
    </div>
  </center>
</body>
</html>

Login background servlet:

package impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import util.DB;
import dao.ILogin;
import entity.Operator;
import entity.Privilege;

public class LoginImpl implements ILogin {
  private PrivilegeImpl1 privilegeImpl = new PrivilegeImpl1();
  private RoleImpl roleImpl = new RoleImpl();
  private List<Privilege> list_privilege;
  private PreparedStatement pst;
  private Operator log_operator;
  private HttpSession session;
  private String checkResult;
  private Connection conn;
  private ResultSet rs;

  // 登录验证
  public String login(HttpServletRequest request, Operator operator) {
    session = request.getSession();
    checkResult = "success";
    log_operator = new Operator();
    try {
      conn = DB.getConn();
      pst = conn
          .prepareStatement("SELECT * FROM operator WHERE ope_name = ?");
      pst.setString(1, operator.getName());
      rs = pst.executeQuery();
      if (!rs.next()) {
        checkResult = "账户不存在,请重新输入!";
        session.setAttribute("isLogin", "false");
      } else {
        if (!operator.getPwd().equals(rs.getString(3))) { 
          checkResult = "The password you entered is incorrect, please try again!"; 
          session.setAttribute("isLogin", "false"); 
        } else { 
          // Successful login 
          session.setAttribute("isLogin", "true"); 

          // Get the complete information of the user 
          log_operator.setId(rs.getInt(1)); 
          log_operator.setName(rs.getString(2)) ; 
          log_operator.setPwd(rs.getString(3)); 
          log_operator.setRole(roleImpl.query("rol_id", 
              rs.getString(4)).get(0)); 
          session.setAttribute("log_operator", log_operator);

          // According to the user, get the permissions corresponding to the corresponding roles 
          list_privilege = privilegeImpl.query("rol_id", log_operator 
              role.getRole().getId() 
              + "");
          List<Privilege> list = new ArrayList<Privilege>();
          list.add(list_privilege.get(0));
          
          for (int i = 1; i < list_privilege.size(); i++) {
                          int y=0;
            for(int x=0;x<list.size();x++){
              
              if(!list.get(x).getMenu_name().equals(
                  list_privilege.get(i).getMenu_name())){
                y++;
              }
            }
            if (y==list.size()) {
              list.add(list_privilege.get(i));

            }

          }
          session.setAttribute("list", list);
          session.setAttribute("list_privilege", list_privilege);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      DB.close(conn, pst, rs);
    }
    return checkResult;
  }
}

Link database:

Link with the most basic jdbc

package util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class DB {
  // 获取数据库连接
  public static Connection getConn() {
    Connection conn = null;
    String url = "jdbc:mysql://localhost:3306/jsp_studentmanager?characterEncoding=utf8";
    String name = "root";
    String pwd = "123456";
    try {
      Class.forName("com.mysql.jdbc.Driver");
      conn = DriverManager.getConnection(url, name, pwd);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return conn;
  // Close the object to release resources
  }

  public static void close(Connection conn, PreparedStatement pst,
      ResultSet rs) {
    try {
      if (rs != null)
        rs.close();
      if (pst != null)
        pst.close();
      if (conn != null)
        conn.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

Part of the table structure:

Student table:

CREATE TABLE `NewTable` (
`stu_id`  int(11) NOT NULL AUTO_INCREMENT ,
`ope_id`  int(11) NULL DEFAULT NULL ,
`stu_no`  varchar(22) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`stu_name`  varchar(22) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`stu_sex`  enum('男','女') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '男' ,
`stu_birth`  date NULL DEFAULT NULL ,
`stu_pic`  varchar(22) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`cla_id`  int(11) NULL DEFAULT NULL ,
PRIMARY KEY (`stu_id`),
FOREIGN KEY (`cla_id`) REFERENCES `classes` (`cla_id`) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`ope_id`) REFERENCES `operator` (`ope_id`) ON DELETE CASCADE ON UPDATE CASCADE,
UNIQUE INDEX `uni_no` (`stu_no`) USING BTREE ,
UNIQUE INDEX `uni_ope` (`ope_id`) USING BTREE ,
INDEX `fk_stu_cla` (`cla_id`) USING BTREE ,
INDEX `fk_stu_ope` (`ope_id`) USING BTREE 
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=13
ROW_FORMAT=COMPACT
;

CREATE DEFINER=`root`@`localhost` TRIGGER `TG_3` AFTER DELETE ON `NewTable`
FOR EACH ROW BEGIN
DELETE FROM operator WHERE ope_id = old.ope_id;
END;

Score Sheet:

CREATE TABLE `NewTable` (
`sco_id`  int(11) NOT NULL AUTO_INCREMENT ,
`sco_daily`  float NULL DEFAULT 0 ,
`sco_exam`  float NULL DEFAULT 0 ,
`sco_count`  float NULL DEFAULT 0 ,
`stu_id`  int(11) NULL DEFAULT NULL ,
`sub_id`  int(11) NULL DEFAULT NULL ,
`cla2sub_id`  int(11) NOT NULL ,
`cla_id`  int(11) NOT NULL ,
PRIMARY KEY (`sco_id`),
FOREIGN KEY (`stu_id`) REFERENCES `student` (`stu_id`) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`sub_id`) REFERENCES `subject` (`sub_id`) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`cla2sub_id`) REFERENCES `cla2sub` (`cla2sub_id`) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (`cla_id`) REFERENCES `classes` (`cla_id`) ON DELETE CASCADE ON UPDATE CASCADE,
UNIQUE INDEX `uni_stu_sub` (`stu_id`, `sub_id`, `cla2sub_id`) USING BTREE ,
INDEX `fk_sco_sub` (`sub_id`) USING BTREE ,
INDEX `fk_sco_stu` (`stu_id`) USING BTREE ,
INDEX `fk_sco_cla` (`cla2sub_id`) USING BTREE ,
INDEX `cla_id` (`cla_id`) USING BTREE 
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=33
ROW_FORMAT=COMPACT
;

Class Schedule:

CREATE TABLE `NewTable` (
`cla_id`  int(11) NOT NULL AUTO_INCREMENT ,
`cla_name`  varchar(22) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`maj_id`  int(11) NULL DEFAULT NULL ,
`cla_tec`  varchar(22) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
PRIMARY KEY (`cla_id`),
FOREIGN KEY (`maj_id`) REFERENCES `major` (`maj_id`) ON DELETE CASCADE ON UPDATE CASCADE,
UNIQUE INDEX `uni_name` (`cla_name`) USING BTREE ,
INDEX `fk_cla_maj` (`maj_id`) USING BTREE 
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=8
ROW_FORMAT=COMPACT
;

CREATE DEFINER=`root`@`localhost` TRIGGER `TG_7` BEFORE DELETE ON `NewTable`
FOR EACH ROW BEGIN
DELETE FROM operator WHERE ope_id IN (SELECT ope_id FROM student WHERE cla_id = old.cla_id);
END;

Okay, let's stop here today, friends, like, favorite, comment, one-click three consecutive walks, see you in the next issue~~

Guess you like

Origin blog.csdn.net/Trouvailless/article/details/124281053