最新jsp学生系统课程设计报告.doc
精品资料jsp学生系统课程设计报告.目 录2.1 整体设计.32.2 模块设计.43.1 登录界面.53.2 学生信息界面.63.3 学生信息查询,编辑,新增界面.73.4 连接数据库.11一 概述 一直以来学生的成绩管理是学校工作中的一项重要内容,我国的大中专院校的学生成绩管理水平普遍不高。随着办学规模的扩大和招生人数的增加,建立一个成绩维护系统是非常必要的。普通的成绩管理已不能适应时代的发展,因为它浪费了许多的人力和物力。在当今信息时代这种传统的管理方法必然被以计算机为基础的信息管理系统所代替。为了提高成绩管理的效率,我选择了学生成绩管理系统作为毕业设计的课题。 本系统在大多数成绩管理系统的基础上,主要增加了教师对成绩的操作,教师改完试卷后不用在往学院的教务处办公室报送成绩,可以直接的把成绩上传到网络上,学生也可以方便快速的查询到自己的成绩,考试后教务管理人员也不必总呆在学院的办公室,他们都不受时间,位置,空间的限制,只要有上网的条件,在家里就可二 系统的结构分析与设计2.1 整体结构设计基于系统的使用对象是管理员,系统根据功能需要分为三个模块,即学生基本信息管理、新增学生信息管理和查询学生信息管理。采用B/S模式,jsp+SQL 2008+JavaBean的技术形式实现。2.1.1 用户角色设计及权限分配 管理员:拥有管理系统所有功能的权限,同时负责系统的用户的增删,服务功能的起停,数据的备份、还原等维护操作;2.1.2 系统模块设计 学生信息管理系统包括三个基本模块:学生基本信息管理、新增学生信息管理和查询学生信息管理。三个模块管理功能不一,同时相互之间又有联系。图12.1.3 系统运行模式设计系统采用B/S(Browser/Server)模式,使管理更加方便和简单,B/S结构中各个客户端只需安装一个具有某种编译功能的构件即可,这个构件就是Web浏览器,用户面对的将是简单统一的浏览器,而不是一个复杂的客户端软件,这就降低了用户的使用难度,系统面对的是全系的师生,大量的学生在使用,B/S是毋庸置疑的选择和必然。2.1.4可行性分析(1).技术可行性:需要用到JAVA基本技术、基于jsp的WEB程序设计、TSQL语言、图片处理、数据库服务等技术。(2).开发环境:课题在JDK+SQL servlet平台下进行设计开发,所使用到的硬件设备有普通PC机一台(现在市场上主流的PC配置已足够),软件有JDK、TOMCAT、SQL 2008、MyEclipse、DERAMWVAER8.0、FREAWORK8.0、photoshop等。(3).运行平台:借助学院现有的WWW服务平台及数据库服务平台即可实现。综上所述本课题的开发具有可行性!2.2 系统模块分析2.2.1 数据需求分析学生信息管理系统就是对学生信息的管理,所以首先我们需要知道的是学生有那些信息,并且是怎样进行分类的。学生基本信息根据要求应该包括学生姓名、密码、联系方式、email、入学信息等。学生唯一一一对应的是学号,所以学号是唯一的主键,其他的都不能是,根据学号我们可以查找学生的姓名信息。2.2.2系统的逻辑结构设计登录界面学生信息界面 新增学生信息查询学生信息删除学生信息编辑学生信息2.2.3数据库设计系统创建一个学生信息数据库(mydlb),当中包含有学生资助信息子系统中的主要数据表:学生信息表(student)其中两个表的结构如下。学生家庭经济情况信息表(student)三 系统的实现3.1系统登陆界面主页是连接登录模块的纽带,我们的理念是给用户简洁、便利的操作界面,如图所示主页只提供了 个简单的链接,让用户能够快速的进入系统。3.2 学生信息界面学生信息界面主要显示学生学号,姓名,查看,编辑,删除等信息。相关代码为: public class ListServlet extends HttpServlet public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException StudentDAO dao = new StudentDAO();List students = dao.getAllStudents();request.setAttribute("students", students);request.getRequestDispatcher("/list.jsp").forward(request, response);public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException doGet(request, response);3.3 学生信息查询,编辑和新增等界面 各功能模块都通过测试,查询得到正确结果,分页功能正常,数据读取状况正常,页面显示正常,响应时间非常快,数据查询过程基本上没有感到浏览器和服务器通信,已经返回了查询结果。相关代码:查询代码:public class XuehaoServlet extends HttpServlet /* * */private static final long serialVersionUID = 1L;public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException String strId = request.getParameter("id");int id = Integer.parseInt(strId);Student student = new Student();StudentDAO dao = new StudentDAO();student = dao.getStudentById(id);request.setAttribute("student", student);request.getRequestDispatcher("/view.jsp").forward(request, response);public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException doGet(request, response);编辑代码:public class ModifyServlet extends HttpServlet public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException String strId = request.getParameter("id");int id = Integer.parseInt(strId);StudentDAO dao = new StudentDAO();Student student = dao.getStudentById(id);request.setAttribute("student", student);request.getRequestDispatcher("/modify.jsp").forward(request, response);public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException doGet(request, response);新增代码:public class AddServlet extends HttpServlet /* * */private static final long serialVersionUID = 1L;public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException String username = request.getParameter("username");String userid = request.getParameter("userid");String password = request.getParameter("psw");String major = request.getParameter("major");String phone =request.getParameter("phone");String email = request.getParameter("email");Student student = new Student();student.setUsername(username);student.setId(Integer.parseInt(userid);student.setPassword(password);student.setMajor(major);student.setphone(phone);student.setEmail(email);StudentDAO dao = new StudentDAO();dao.addStudent(student);response.sendRedirect("list.do");public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException doGet(request, response);3.4 连接数据库public class StudentDAO private static final String DRIVER = "com.mysql.jdbc.Driver"private static final String URL = "jdbc:mysql:/localhost:3306/mydlb"public List getAllStudents() Connection conn = getConn();Statement stmt = null;ResultSet rs = null;String sqlValue = "SELECT * FROM student"List list = new ArrayList();try stmt = conn.createStatement();rs = stmt.executeQuery(sqlValue);while (rs.next() Student stu = new Student();stu.setId(rs.getInt("id");stu.setUsername(rs.getString("username");stu.setPassword(rs.getString("password");stu.setMajor(rs.getString("major");stu.setphone(rs.getString("phone");stu.setEmail(rs.getString("email");stu.setEnroll_date(rs.getString("enroll_date");list.add(stu);return list; catch (Exception ex) System.out.println("数据库操作发生错误!");ex.printStackTrace();return null; finally try if (rs != null) rs.close();if (stmt != null) stmt.close();if (conn != null) conn.close(); catch (SQLException ex) System.out.println("Close Error!");/ex.printStackTrace();public Student getStudentById(int id) Connection conn = getConn();Statement stmt = null;ResultSet rs = null;String sqlValue = "SELECT * FROM student WHERE id=" + id;try stmt = conn.createStatement();rs = stmt.executeQuery(sqlValue);Student stu = new Student();while (rs.next() stu.setId(rs.getInt("id");stu.setUsername(rs.getString("username");stu.setPassword(rs.getString("password");stu.setMajor(rs.getString("major");stu.setphone(rs.getString("phone");stu.setEmail(rs.getString("email");stu.setEnroll_date(rs.getString("enroll_date");break;return stu; catch (Exception ex) System.out.println("数据库操作发生错误!");return null; finally try if (rs != null) rs.close();if (stmt != null) stmt.close();if (conn != null) conn.close(); catch (SQLException ex) System.out.println("Close Error!");/ex.printStackTrace();public void addStudent(Student student) Connection conn = getConn();Statement stmt = null;String sqlValue = "INSERT INTO student(id,username,password,major,phone,email,enroll_date) VALUES (" + student.getId() + ",'"+ student.getUsername()+ "','"+ student.getPassword()+ "','"+ student.getMajor()+ "','"+ student.getphone()+"','"+ student.getEmail()+ "','"+ (new java.util.Date().toString() + "')"try stmt = conn.createStatement();stmt.executeUpdate(sqlValue); catch (Exception ex) System.out.println("数据库操作发生错误!");ex.printStackTrace(); finally try if (stmt != null) stmt.close();if (conn != null) conn.close(); catch (SQLException ex) System.out.println("Close Error!");/ex.printStackTrace();public void updateStudent(Student student) Connection conn = getConn();Statement stmt = null;String sqlValue = "UPDATE student SET username='"+ student.getUsername() + "', password='"+ student.getPassword() + "', major='" + student.getMajor()+"', phone='" + student.getphone() + "', email='" + student.getEmail() + "' WHERE id="+ student.getId();try stmt = conn.createStatement();stmt.executeUpdate(sqlValue); catch (Exception ex) System.out.println("数据库操作发生错误!");ex.printStackTrace(); finally try if (stmt != null) stmt.close();if (conn != null) conn.close(); catch (SQLException ex) System.out.println("Close Error!");/ex.printStackTrace();public void removeStudent(int id) Connection conn = getConn();Statement stmt = null;String sqlValue = "DELETE FROM student WHERE id=" + id;try stmt = conn.createStatement();stmt.executeUpdate(sqlValue); catch (Exception ex) System.out.println("数据库操作发生错误!");ex.printStackTrace(); finally try if (stmt != null) stmt.close();if (conn != null) conn.close(); catch (SQLException ex) System.out.println("Close Error!");/ex.printStackTrace();private Connection getConn() try Class.forName(DRIVER);Connection conn = DriverManager.getConnection(URL, "root", "12345");return conn; catch (Exception ex) System.out.println("不能获取数据库连接!");/ex.printStackTrace();return null;public Student getStudentByUsername(String strUsername) Connection conn = getConn();Statement stmt = null;ResultSet rs = null;String sqlValue = "SELECT * FROM student WHERE username=" + strUsername;try stmt = conn.createStatement();rs = stmt.executeQuery(sqlValue);Student stu = new Student();while (rs.next() stu.setId(rs.getInt("id");stu.setUsername(rs.getString("username");stu.setPassword(rs.getString("password");stu.setMajor(rs.getString("major");stu.setphone(rs.getString("phone");stu.setEmail(rs.getString("email");stu.setEnroll_date(rs.getString("enroll_date");break;return stu; catch (Exception ex) System.out.println("数据库操作发生错误!");return null; finally try if (rs != null) rs.close();if (stmt != null) stmt.close();if (conn != null) conn.close(); catch (SQLException ex) System.out.println("Close Error!");/ex.printStackTrace();四 课程设计总结通过对该系统的设计使我了解到课设的过程是艰辛的,但是收获是巨大的。首先,我们再一次的加深巩固了对已有的知识的理解及认识 其次,我们第一次将课本知识运用到了实际设计,使得所学知识在更深的层次上得到了加深。再次,因为这次课程设计牵扯了许多我们没有详细讲的jsp内容,这些方面确实存有一定难度,这对我们来讲都是一种锻炼,培养了我们集体合作的能力以及自学、查阅搜集资料的能力;再有,程序设计中,我们曾经面临过失败、品味过茫然,同时我们也学会了什么是坚持做学问真的没什么笨与不笨之分 ,只要勤于看书·向别人提问,许多东西都可以由不会变到会的 关键在自己 只要我们坚持下来,就没什么不可以!看着程序一次次的运行错误我们真的有些失望 ,但当我们一次次得把错误改正我们又是那么的激动,我们看着自己把原来的程序改的面目全非又改回来其中的乐趣怕是只有我们自己才能体会,我们不是怕失败,我们怕的是失败后依然不成功。这就是我们意志、耐力的胜利,在今后的日子里,它必将成为我们的宝贵财富。