eclipse和数据库实现学生成绩查询系统web界面

您所在的位置:网站首页 网上查分的软件 eclipse和数据库实现学生成绩查询系统web界面

eclipse和数据库实现学生成绩查询系统web界面

2024-07-15 02:42:17| 来源: 网络整理| 查看: 265

学生成绩查询系统(eclipse+SQLserver+tomact) 开发环境系统实现总结+参考

开发环境

比较懒。 如果要做这种类似的系统大概都知道这些软件吧。所以这个部分比较粗糙

Java环境 下载安装eclipse和JDK,配置相应的Java环境 安装JDK的教程 安装eclipse的教程MySQL数据库 安装MySQL,配置相应的服务 MySQL安装及图形化的教程Tomact服务器 下载Tomact的压缩包,配置环境变量 安装Tomact的教程 系统实现

数据库 创建课程信息表、学生信息表、成绩基本信息表,其中课程信息表中的课程号是成绩信息表中课程号的外键,学生信息表中的学号是成绩信息表中学号的外键。

实现功能 登陆功能;课程信息管理;学生信息管理;查询成绩。

项目结构 在这里插入图片描述 在这里插入图片描述

部分代码

数据库连接:

package util; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class DBUtil { private static final String driver = "com.mysql.jdbc.Driver"; private static final String url = "jdbc:mysql://localhost:3306/studentmanagement?useUnicode=true&characterEncoding=UTF-8";//连接数据库 private static final String username = "root"; private static final String password = "123456"; private static Connection conn; static { try { Class.forName(driver); } catch (Exception ex) { ex.printStackTrace(); } } public static Connection getConnection() throws SQLException { if (conn == null) { conn = DriverManager.getConnection(url, username, password); return conn; } return conn; } }

登录:

public class LoginServlet extends HttpServlet{ public LoginServlet() { super(); } /** * Destruction of the servlet. */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=utf-8"); HttpSession session = request.getSession(); String path = request.getContextPath(); String action = request.getParameter("action"); if ("login".equals(action)) { String inumber = request.getParameter("inumber"); String password = request.getParameter("password"); String identity = request.getParameter("identity"); String[] isUserCookies = request.getParameterValues("isUseCookie"); if ("student".equals(identity)) { // 如果登录的是学生 StudentDao studentDao = new StudentDao(); Student student = new Student(); try { student.setSid(Integer.parseInt(inumber)); } catch (Exception ex) { response.sendRedirect(path + "/failure.jsp"); return ; } student.setSpwd(password); if (studentDao.isValid(student)) { // 账号密码合法 session.setAttribute("student", student); if (isUserCookies != null && isUserCookies.length > 0) { saveCookie(inumber, password, response); } else { notSaveCookie(inumber, password, request, response); } response.sendRedirect(path + "/studentMain.jsp"); } else { // 不合法 response.sendRedirect(path + "/failure.jsp"); } } else if ("admin".equals(identity)) { // 如果登录的是管理员 if ("001".equals(inumber) && "001".equals(password)) { // 账号密码合法 session.setAttribute("admin", "管理员"); if (isUserCookies != null && isUserCookies.length > 0) { saveCookie(inumber, password, response); } else { notSaveCookie(inumber, password, request, response); } response.sendRedirect(path + "/adminMain.jsp"); } else { // 不合法 response.sendRedirect(path + "/failure.jsp"); } } else { response.sendRedirect(path + "/teacherMain.jsp"); } } else if ("logout".equals(action)) { // 退出登录 session.invalidate(); response.sendRedirect(path + "/index.jsp"); } } // 记住账号密码 public void saveCookie(String inumber, String password, HttpServletResponse response) { Cookie inumberCookie = new Cookie("inumber", inumber); Cookie passwordCookie = new Cookie("password", password); // 设置Cookie存储路径 否则index中取不到…… inumberCookie.setPath("/"); passwordCookie.setPath("/"); inumberCookie.setMaxAge(864000); // 10 days passwordCookie.setMaxAge(864000); response.addCookie(inumberCookie); response.addCookie(passwordCookie); } // 不记住账号密码 public void notSaveCookie(String inumber, String password, HttpServletRequest request, HttpServletResponse response) { Cookie[] cookies = request.getCookies(); for (Cookie cookie: cookies) { if (cookie.getName().equals("inumber") || cookie.getName().equals("password")) { cookie.setMaxAge(0); response.addCookie(cookie); } } } public void init() throws ServletException { // Put your code here } }

学生登录的页面:

学生登录 * { /* border:1px solid #F00; */ } body { background:#AAFFEE url(images/studentMain.jpg); text-align:center; } #wel { margin: 100px 400px 0 400px; border:1px solid #000; } a { font-size:1.5em; background: #BBFFEE; } a:hover {background: #00BBFF;} 欢迎登录, 选课 查看已选课程 退出登录 效果 在这里插入图片描述 在这里插入图片描述 在这里插入图片描述

在这里插入图片描述 在这里插入图片描述

总结+参考

部分功能存在一些问题,但是跳转是没有问题的。是在别人的代码基础之上自己调试出来的,由于时间关系没有好好完善页面、功能等。jsp感觉和html网页差不多,只是在里面加入了Java语言,不难上手。

Jsp+serlvet+mysql实现学生成绩管理系统



【本文地址】

公司简介

联系我们

今日新闻


点击排行

实验室常用的仪器、试剂和
说到实验室常用到的东西,主要就分为仪器、试剂和耗
不用再找了,全球10大实验
01、赛默飞世尔科技(热电)Thermo Fisher Scientif
三代水柜的量产巅峰T-72坦
作者:寞寒最近,西边闹腾挺大,本来小寞以为忙完这
通风柜跟实验室通风系统有
说到通风柜跟实验室通风,不少人都纠结二者到底是不
集消毒杀菌、烘干收纳为一
厨房是家里细菌较多的地方,潮湿的环境、没有完全密
实验室设备之全钢实验台如
全钢实验台是实验室家具中较为重要的家具之一,很多

推荐新闻


图片新闻

实验室药品柜的特性有哪些
实验室药品柜是实验室家具的重要组成部分之一,主要
小学科学实验中有哪些教学
计算机 计算器 一般 打孔器 打气筒 仪器车 显微镜
实验室各种仪器原理动图讲
1.紫外分光光谱UV分析原理:吸收紫外光能量,引起分
高中化学常见仪器及实验装
1、可加热仪器:2、计量仪器:(1)仪器A的名称:量
微生物操作主要设备和器具
今天盘点一下微生物操作主要设备和器具,别嫌我啰嗦
浅谈通风柜使用基本常识
 众所周知,通风柜功能中最主要的就是排气功能。在

专题文章

    CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭