基于java eclipse+jsp+mysql+servlet+Spring的学生信息管理系统基础版

历览千载书,时时见遗烈。这篇文章主要讲述基于java eclipse+jsp+mysql+servlet+Spring的学生信息管理系统基础版相关的知识,希望能为你提供帮助。


项目背景【基于java eclipse+jsp+mysql+servlet+Spring的学生信息管理系统基础版】学生信息档案的管理对于学校的管理者来说至关重要,学生信息是高等学校非常重要的一项数据资源,是一个教育单位不可缺少一部分。特别是近几年来,国家政策的调整,我国高等院校大规模的扩招,给高等院校的教学管理、学生管理、后勤管理等方面都带来不少的冲击。其包含的数据量大,涉及的人员面广,而且需要及时更新,故较为复杂,难以单纯地依靠人工管理,而且传统的人工管理方式既不易于规范化,管理效率也不高,我国各类高等院校中还有相当一部分学生档案管理还停留在纸介质的基础上,尤其是中、小学对学生档案的管理更是落后,这样的管理机制已经不能适应时代发展的要求,其管理方法将浪费许多人力和物力。随着科学技术的不断提高,计算机科学与技术日渐成熟,计算机应用的普及已进入人类社会生活的各个领域,并发挥着越来越重要的作用。这种传统的手工管理模式必然被以计算机为物质基础的信息管理方法所取代。
功能设计主要功能:用户不同角色登录(老师、学生、管理员)
系统首页介绍
学生管理:添加学生、查看学生列表信息、查看学生资料
老师管理:添加老师、查看老师列表信息、查看老师资料
成绩管理:查看成绩信息、修改成绩
个人中心:修改个人资料、头像等、注销退出
角色设计拥有管理员、老师、学生三种角色、每个角色对应不同菜单权限
主要技术用的技术都是比较基础好学通俗易懂的java jsp+mysql+servlet+jdbc+jquery+html+css等
具体功能实现登录:
根据不同账号角色进行登录

基于java eclipse+jsp+mysql+servlet+Spring的学生信息管理系统基础版

文章图片
< script src="https://www.songbingjia.com/android/js/login.js" type="text/javascript"> < /script>
< link href="https://www.songbingjia.com/android/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="https://www.songbingjia.com/android/登录" onclick="login()">
< /div>
< /div>
< /center>
< /body>
< /html>
登录后台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 = "您输入的密码不正确,请重新输入!";
session.setAttribute("isLogin", "false");
else
// 登录成功
session.setAttribute("isLogin", "true");

// 获得该用户的完整信息
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);

// 根据用户,获取对应的角色对应的权限
list_privilege = privilegeImpl.query("rol_id", log_operator
.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;


链接数据库:
利用最基本的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;


// 关闭对象 释放资源
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();



部分表结构:学生表:
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;

成绩表:
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
;

班级表:
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;


好了,今天就到这儿吧,小伙伴们点赞、收藏、评论,一键三连走起呀,下期见~~



    推荐阅读