Java+Servlet+JSP+Mysql+Tomcat实现Web学生选课管理系统(下)

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: Java+Servlet+JSP+Mysql+Tomcat实现Web学生选课管理系统

StudentDaoImpl.java

package com.bluehonour.sscs.dao.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.bluehonour.sscs.dao.StudentDao;
import com.bluehonour.sscs.entity.ClassInfo;
import com.bluehonour.sscs.entity.CriteriaStudent;
import com.bluehonour.sscs.entity.Student;
import com.bluehonour.sscs.util.DBUtils;
public class StudentDaoImpl implements StudentDao {
  @Override
  public int save(Student stu) {
    String sql = "insert into t_student(password,sname,phone,sex,birthday,classno,remark) values(?,?,?,?,?,?,?)";
    Object[] params = { stu.getPassword(), stu.getSname(), stu.getPhone(), stu.getSex(), stu.getBirthday(),
        stu.getClassno(), stu.getRemark() };
    return DBUtils.executeUpdate(sql, params);
  }
  @Override
  public List<Student> findAll() {
    Connection connection = null;
    PreparedStatement preparedStatement = null;
    ResultSet rs = null;
    Student student = null;
    List<Student> stuList = new ArrayList<Student>();
    try {
      // 建立连接
      connection = DBUtils.getConnection();
      // 向数据库发送sql命令并得到结果
      String sql = "select * from t_student";
      preparedStatement = connection.prepareStatement(sql);
      rs = preparedStatement.executeQuery();
      // 处理返回结果
      while (rs.next()) {
        // 取出结果集当前行各个字段的值
        int sno = rs.getInt("sno");
        String password = rs.getString("password");
        String sname = rs.getString("sname");
        long phone = rs.getLong("phone");
        String sex = rs.getString("sex");
        Date birthday = rs.getDate("birthday");
        int classno = rs.getInt("classno");
        String remark = rs.getString("remark");
        // 封装成对象
        student = new Student(sno,password, sname, phone, sex, birthday, classno, remark);
        stuList.add(student);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      DBUtils.closeAll(rs, preparedStatement, connection);
    }
    return stuList;
  }
  @Override
  public int del(int sno) {
    String sql = "delete  from t_student where sno = ?";
    Object[] params = {sno };
    return DBUtils.executeUpdate(sql, params);
  }
  @Override
  public Student findById(int sno) {
    Connection connection = null;
    PreparedStatement preparedStatement = null;
    ResultSet rs = null;
    Student student = null;
    try {
      // 建立连接
      connection = DBUtils.getConnection();
      // 向数据库发送sql命令并得到结果
      String sql = "select * from t_student where sno = " + sno;
      preparedStatement = connection.prepareStatement(sql);
      rs = preparedStatement.executeQuery();
      // 处理返回结果
      if (rs.next()) {
        // 取出结果集当前行各个字段的值
        String password = rs.getString("password");
        String sname = rs.getString("sname");
        long phone = rs.getLong("phone");
        String sex = rs.getString("sex");
        Date birthday = rs.getDate("birthday");
        int classno = rs.getInt("classno");
        String remark = rs.getString("remark");
        // 封装成对象
        student = new Student(sno,password, sname, phone, sex, birthday, classno, remark);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      DBUtils.closeAll(rs, preparedStatement, connection);
    }
    return student;
  }
  @Override
  public int update(Student stu) {
    String sql = "update t_student set sname=?,password=?,phone=?,birthday=?,sex=?,classno=?,remark=? where sno=?";
    Object[] params = { stu.getSname(),stu.getPassword(),stu.getPhone(),stu.getBirthday(),stu.getSex(),stu.getClassno(),
         stu.getRemark(),stu.getSno() };
    return DBUtils.executeUpdate(sql, params);
  }
  @Override
  public Student find(String sno, String password) {
    Connection connection = null;
    PreparedStatement preparedStatement = null;
    ResultSet rs = null;
    Student student = null;
    try {
      //建立连接
      connection = DBUtils.getConnection();
      //向数据库发送sql命令并得到结果
      String sql = "select * from t_student where sno = ? and password = ?";
      preparedStatement = connection.prepareStatement(sql);
      preparedStatement.setString(1, sno);
      preparedStatement.setString(2, password);
      rs = preparedStatement.executeQuery();
      //处理返回结果
      if(rs.next()) {
        //取出结果集当前行各个字段的值
        String sname = rs.getString("sname");
        long phone = rs.getLong("phone");
        String sex = rs.getString("sex");
        Date birthday = rs.getDate("birthday");
        int classno = rs.getInt("classno");
        String remark = rs.getString("remark");
        //封装成对象
        student = new Student(Integer.parseInt(sno), password, sname, phone, sex, birthday, classno, remark);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      //关闭数据库资源
      DBUtils.closeAll(rs, preparedStatement, connection);
    }
    return student;
  }
  @Override
  public List<ClassInfo> getClassInfo() {
    Connection connection = null;
    PreparedStatement preparedStatement = null;
    ResultSet rs = null;
    ClassInfo clazz = null;
    List<ClassInfo> list = new ArrayList<ClassInfo>();
    try {
      //建立连接
      connection = DBUtils.getConnection();
      //向数据库发送sql命令并得到结果
      String sql = "select * from t_class";
      preparedStatement = connection.prepareStatement(sql);
      rs = preparedStatement.executeQuery();
      //处理返回结果
      while(rs.next()) {
        //取出结果集当前行各个字段的值
        int classno = rs.getInt("classno");
        String cname = rs.getString("cname");
        String cteacher = rs.getString("cteacher");
        String classroom = rs.getString("classroom");
        //封装成对象
        clazz = new ClassInfo(classno, cname, cteacher, classroom);
        list.add(clazz);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      //关闭数据库资源
      DBUtils.closeAll(rs, preparedStatement, connection);
    }
    return list;
  }
  @Override
  public List<Student> getForListWithCriteriaStudent(CriteriaStudent student) {
    Connection connection = null;
    PreparedStatement preparedStatement = null;
    ResultSet rs = null;
    List<Student> stuList = new ArrayList<Student>();
    try {
      // 建立连接
      connection = DBUtils.getConnection();
      // 向数据库发送sql命令并得到结果
      StringBuffer sql = new StringBuffer();
      sql.append("select * from t_student");
      if(!student.getSno().equals("")) {
        sql.append(" and sno like '%"+ student.getSno()  +"%'");
      }
      if(!student.getSname().equals("")) {
        sql.append(" and sname like '%"+ student.getSname() +"%'");
      }
      if(!student.getSex().equals("")) {
        sql.append(" and sex ='"+ student.getSex() +"'");
      }
      if(!student.getClassno().equals("")) {
        sql.append(" and classno like '%"+ student.getClassno() +"%'");
      }
      if(!student.getRemark().equals("")) {
        sql.append(" and remark='"+ student.getRemark() +"'");
      }
      String SQL = sql.toString();
      SQL = SQL.replaceFirst("and", "where");
      System.out.println(SQL);
      preparedStatement = connection.prepareStatement(SQL);
      rs = preparedStatement.executeQuery();
      // 处理返回结果
      while (rs.next()) {
        // 取出结果集当前行各个字段的值
        int sno = rs.getInt("sno");
        String password = rs.getString("password");
        String sname = rs.getString("sname");
        long phone = rs.getLong("phone");
        String sex = rs.getString("sex");
        Date birthday = rs.getDate("birthday");
        int classno = rs.getInt("classno");
        String remark = rs.getString("remark");
        // 封装成对象
        Student stu = new Student(sno,password, sname, phone, sex, birthday, classno, remark);
        stuList.add(stu);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      DBUtils.closeAll(rs, preparedStatement, connection);
    }
    return stuList;
  }
}

TeacherCourseDaoImpl.javab

package com.bluehonour.sscs.dao.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.bluehonour.sscs.dao.TeacherCourseDao;
import com.bluehonour.sscs.entity.Course;
import com.bluehonour.sscs.entity.Teacher;
import com.bluehonour.sscs.util.DBUtils;
public class TeacherCourseDaoImpl implements TeacherCourseDao {
  @Override
  public int save(int cno, int tno) {
    String sql = "insert into t_tc values(?,?)";
    Object[] params = {cno,tno};
    return DBUtils.executeUpdate(sql, params);
  }
  @Override
  public int delete(int cno, int tno) {
    String sql = "delete from t_tc where cno = ? and tno = ?";
    Object[] params = {cno,tno};
    return DBUtils.executeUpdate(sql, params);
  }
  @Override
  public List<Course> findAll() {
    Connection connection = null;
    PreparedStatement preparedStatement = null;
    ResultSet rs = null;
    List<Course> list = new ArrayList<Course>();
    try {
      // 建立连接
      connection = DBUtils.getConnection();
      // 向数据库发送sql命令并得到结果
      String sql = "select * from t_course c"
          + " join t_tc tc"
          + " on (c.cno = tc.cno)"
          + " join t_teacher t"
          + " on (tc.tno = t.tno)"
          + " order by c.cno";
      preparedStatement = connection.prepareStatement(sql);
      rs = preparedStatement.executeQuery();
      // 处理返回结果
      while (rs.next()) {
        // 取出结果集当前行课程各个字段的值
        int cno = rs.getInt("cno");
        String name = rs.getString("name");
        int credit = rs.getInt("credit");
        Date periodstart = rs.getDate("periodstart");
        Date periodend = rs.getDate("periodend");
        // 封装成课程对象
        Course course = new Course(cno,name, credit, periodstart, periodend);
        //取出结果集中教师各个字段的值
        int tno = rs.getInt("tno");
        String tname = rs.getString("tname");
        String password = rs.getString("password");
        long phone = rs.getLong("phone");
        Date hiredate = rs.getDate("hiredate");
        String remark = rs.getString("remark");
        //封装成教师对象
        Teacher teacher = new Teacher(tno,tname, password, phone, hiredate, remark);
        //将教师加入课程
        course.setTeacher(teacher);
        list.add(course);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      DBUtils.closeAll(rs, preparedStatement, connection);
    }
    return list;
  }
}

TeacherDaoImpl.java

package com.bluehonour.sscs.dao.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.bluehonour.sscs.dao.TeacherDao;
import com.bluehonour.sscs.entity.Course;
import com.bluehonour.sscs.entity.Student;
import com.bluehonour.sscs.entity.Teacher;
import com.bluehonour.sscs.util.DBUtils;
public class TeacherDaoImpl implements TeacherDao {
  @Override
  public int save(Teacher teacher) {
    String sql = "insert into t_teacher(tname,password,phone,hiredate,remark)  values(?,?,?,?,?) ";
    Object[] params = {teacher.getTname(),teacher.getPassword(),teacher.getPhone(),teacher.getHiredate(),teacher.getRemark()};
    return DBUtils.executeUpdate(sql, params);
  }
  @Override
  public List<Teacher> findAll() {
    Connection connection = null;
    PreparedStatement preparedStatement = null;
    ResultSet rs = null;
    List<Teacher> list = new ArrayList<Teacher>();
    try {
      // 建立连接
      connection = DBUtils.getConnection();
      // 向数据库发送sql命令并得到结果
      String sql = "select * from t_teacher order by tno";
      preparedStatement = connection.prepareStatement(sql);
      rs = preparedStatement.executeQuery();
      // 处理返回结果
      while (rs.next()) {
        // 取出结果集当前行各个字段的值
        int tno = rs.getInt("tno");
        String tname = rs.getString("tname");
        String password = rs.getString("password");
        long phone = rs.getLong("phone");
        Date hiredate = rs.getDate("hiredate");
        String remark = rs.getString("remark");
        // 封装成对象
        Teacher teacher = new Teacher(tno,tname, password, phone, hiredate, remark);
        list.add(teacher);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      DBUtils.closeAll(rs, preparedStatement, connection);
    }
    return list;
  }
  @Override
  public int delete(int tno) {
    String sql = "delete  from t_teacher where tno = ?";
    Object[] params = {tno };
    return DBUtils.executeUpdate(sql, params);
  }
  @Override
  public Teacher findById(int tno) {
    Connection connection = null;
    PreparedStatement preparedStatement = null;
    ResultSet rs = null;
    Teacher teacher = null;
    try {
      // 建立连接
      connection = DBUtils.getConnection();
      // 向数据库发送sql命令并得到结果
      String sql = "select * from t_teacher where tno = " + tno;
      preparedStatement = connection.prepareStatement(sql);
      rs = preparedStatement.executeQuery();
      // 处理返回结果
      if (rs.next()) {
        // 取出结果集当前行各个字段的值
        String tname = rs.getString("tname");
        String password = rs.getString("password");
        long phone = rs.getLong("phone");
        Date hiredate = rs.getDate("hiredate");
        String remark = rs.getString("remark");
        // 封装成对象
        teacher = new Teacher(tno, tname, password, phone, hiredate, remark);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      DBUtils.closeAll(rs, preparedStatement, connection);
    }
    return teacher;
  }
  @Override
  public int update(Teacher teacher) {
    String sql = "update t_teacher set tname=?,password=?,phone=?,hiredate=?,remark=? where tno=?";
    Object[] params = {teacher.getTname(),teacher.getPassword(),teacher.getPhone(),teacher.getHiredate(),teacher.getRemark(),teacher.getTno()};
    return DBUtils.executeUpdate(sql, params);
  }
  @Override
  public List<Course> getAssumeCourse(int tno) {
    Connection connection = null;
    PreparedStatement preparedStatement = null;
    ResultSet rs = null;
    Course course = null;
    List<Course> list = new ArrayList<>();
    try {
      // 建立连接
      connection = DBUtils.getConnection();
      // 向数据库发送sql命令并得到结果
      String sql = "select c.* from t_tc tc " + 
          "LEFT JOIN t_teacher t on t.tno = tc.tno " + 
          "LEFT JOIN t_course c on c.cno = tc.cno " + 
          "where tc.tno = " + tno ;
      preparedStatement = connection.prepareStatement(sql);
      rs = preparedStatement.executeQuery();
      // 处理返回结果
      while (rs.next()) {
        // 取出结果集当前行各个字段的值
        int cno = rs.getInt("cno");
        String name = rs.getString("name");
        int credit = rs.getInt("credit");
        Date periodstart = rs.getDate("periodstart");
        Date periodend = rs.getDate("periodend");
        // 封装成对象
        course = new Course(cno,name, credit, periodstart, periodend);
        list.add(course);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      DBUtils.closeAll(rs, preparedStatement, connection);
    }
    return list;
  }
}

addAdmin.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
  pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>增加管理员</title>
<link rel="stylesheet" type="text/css" href="<c:url value='/css/add.css'/>">
 <script type="text/javascript" src="${pageContext.request.contextPath }/My97DatePicker/WdatePicker.js"></script>
 <script type="text/javascript"
  src="${pageContext.request.contextPath }/kindeditor/kindeditor-all.js"></script>
<script type="text/javascript"
  src="${pageContext.request.contextPath }/kindeditor/lang/zh_CN.js"></script>
 <script>
  KindEditor.ready(function(K) {
    filterMode: false,//是否开启过滤模式
    window.editor = K.create('#introduction-id');
  });
</script>
</head>
<body>
  <div class="nav">
  <%--  ${error }
    <div><img src="${pageContext.request.contextPath }/images/register_admin.jpg"></div> --%>
    <%
      if(request.getAttribute("error") != null){
    %>
        <div><img src="${pageContext.request.contextPath }/images/add_admin_error.jpg"></div>
    <%
      } else{
    %>
        <div><img src="${pageContext.request.contextPath }/images/register_admin.jpg"></div>
    <%
      } 
    %>
    <div class="nav1">
      <form action="${pageContext.request.contextPath }/addAdmin.do" method="post">
        <p>
          <label for="userId">管理员账号:</label> <input type="text" name="userId" id="userId""><span>请输入4-10位用户名</span>
        </p>
        <p>
          <label for="userName">真实姓名:</label> <input type="text" name="userName"
            id="userName" value=""><span>请输入您的真实姓名</span>
        </p>
        <p>
          <label for="passWord">密码:</label> <input type="password" name="passWord"
            id="passWord" value="" size="20px"><span>密码为6-16位</span>
        </p>
        <p>
          <label for="rePassWord">确认密码:</label> <input type="password" name="rePassWord"
            id="rePassWord" value="" size="20px"><span>请再次输入密码</span>
        </p>
        <p>
          <label for="age">年龄:</label> <input type="text" name="age" id="age" value=""><span>请输入年龄</span>
        </p>
        <p>
          <label for="score">成绩:</label> <input type="text" name="score" id="score" value=""><span>请输入成绩</span>
        </p>
        <p>
          <label for="enterDate">入职时间:</label> <input type="text" name="enterDate"
            id="enterDate" value="" onfocus="WdatePicker({highLineWeekDay:true,isShowToday:true,isShowWeek:true})"><span>请输入入职时间</span>
        </p>
        <p>
          <label for="introduction">简介:</label>
                  <textarea  class="no" name="introduction" id="introduction-id"
            style=" width: 700px; height: 200px; visibility: hidden; display: block;">
          </textarea>
        </p>
        <button class="sub">
          <img src="${pageContext.request.contextPath }/images/button.gif">
        </button>
      </form>
    </div>
  </div>
  <script>
    window.onload = function(e) {
      var form = document.querySelector('form');
      var userId = document.querySelector('#userId');
      var userName = document.querySelector('#userName');
      var passWord = document.querySelector('#passWord');
      var rePassWord = document.querySelector('#rePassWord');
      var age = document.querySelector('#age');
      var score = document.querySelector('#score');
      var enterDate = document.querySelector('#enterDate');
      var span = document.querySelectorAll('span');
      //onsubmit事件
      form.onsubmit = function(e) {
        var userId = checkUserId();
        if (!userId) {
          return false;
        }
        var username = checkUserName();
        if (!username) {
          return false;
        }
        var password = checkPassWord();
        if (!password) {
          return false;
        }
        var rePassWord = checkRePassWord();
        if (!rePassWord) {
          return false;
        }
        var age = checkAge();
        if (!age) {
          return false;
        }
        var score = checkScore();
        if (!score) {
          return false;
        }
        var enterDate = checkEnterDate();
        if (!enterDate) {
          return false;
        }
        return true;
      };
      //onblur失去焦点事件
      userId.onblur = function(e) {
        checkUserId();
      };
      userName.onblur = function(e) {
        checkUserName();
      };
      passWord.onblur = function(e) {
        checkPassWord();
      };
      rePassWord.onblur = function(e) {
        checkRePassWord();
      };
      age.onblur = function(e) {
        checkAge();
      };
      score.onblur = function(e) {
        checkScore();
      };
      enterDate.onblur = function(e) {
        checkEnterDate();
      };
      //---------------------------------函数封装-------------------------------------------------------------
      //管理员账户(3-10位)
      function checkUserId(e) {
        if (userId.value.length == 0) {
          span[0].innerText = '账户不能为空';
          span[0].className = 'danger';
          return false;
        }
        var pattern = /^[A-Za-z0-9]{3,10}$/;
        if (!pattern.test(userId.value)) {
          span[0].innerText = '账户格式错误,请重新输入';
          span[0].className = 'danger';
          return false;
        }
        span[0].innerText = '管理员账户输入正确';
        span[0].className = 'success';
        return true;
      }
      //真实姓名(2-4位汉字)
      function checkUserName(e) {
        if (userName.value.length == 0) {
          span[1].innerText = '真实姓名不能为空';
          span[1].className = 'danger';
          return false;
        }
        var pattern = /^[\u4e00-\u9fa5]{2,4}$/;
        if (!pattern.test(userName.value)) {
          span[1].innerText = '真实姓名格式错误,请重新输入';
          span[1].className = 'danger';
          return false;
        }
        span[1].innerText = '真实姓名输入正确';
        span[1].className = 'success';
        return true;
      }
      //登录密码(6-16位)
      function checkPassWord(e) {
        if (passWord.value.length == 0) {
          span[2].innerText = '密码不能为空';
          span[2].className = 'danger';
          return false;
        }
        var pattern = /^[A-Za-z0-9]{6,16}$/;
        if (!pattern.test(passWord.value)) {
          span[2].innerText = '密码不符合格式,请重新输入';
          span[2].className = 'danger';
          return false;
        }
        span[2].innerText = '密码输入正确';
        span[2].className = 'success';
        return true;
      }
      //重复登录密码
      function checkRePassWord(e) {
        if (rePassWord.value.length == 0) {
          span[3].innerText = '重复密码不能为空';
          span[3].className = 'danger';
          return false;
        }
        if (rePassWord.value != passWord.value) {
          span[3].innerText = '两次输入的密码不一致,请重新输入';
          span[3].className = 'danger';
          return false;
        }
        span[3].innerText = '两次密码一致';
        span[3].className = 'success';
        return true;
      }
      //年龄(1-3位)
      function checkAge(e) {
        if (age.value.length == 0) {
          span[4].innerText = '年龄不能为空';
          span[4].className = 'danger';
          return false;
        }
        var pattern = /^[1-9]{1,3}$/;
        if (!pattern.test(age.value)) {
          span[4].innerText = '年龄格式错误,请重新输入';
          span[4].className = 'danger';
          return false;
        }
        span[4].innerText = '年龄输入正确';
        span[4].className = 'success';
        return true;
      }
      //成绩
      function checkScore(e) {
        if (score.value.length == 0) {
          span[5].innerText = '成绩不能为空';
          span[5].className = 'danger';
          return false;
        }
        /*   var pattern = /^[0-9]+\.?[0-9]*$/; */
        var pattern = /^[0-9]+\.?[0-9]*$/;
        if (!pattern.test(score.value)) {
          span[5].innerText = '成绩格式错误,请重新输入';
          span[5].className = 'danger';
          return false;
        }
        span[5].innerText = '成绩输入正确';
        span[5].className = 'success';
        return true;
      }
      //入职时间(格式xxxx-xx-xx)
      function checkEnterDate(e) {
        if (enterDate.value.length == 0) {
          span[6].innerText = '入职时间不能为空';
          span[6].className = 'danger';
          return false;
        }
        var pattern = /^[0-9]{4}\-?[0-9]{1,2}\-?[0-9]{1,2}$/;
        if (!pattern.test(enterDate.value)) {
          span[6].innerText = '时间格式:xxxx-xx-xx';
          span[6].className = 'danger';
          return false;
        }
        span[6].innerText = '时间格式正确';
        span[6].className = 'success';
        return true;
      }
    }
  </script>
</body>
</html>

addCourse.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>添加学生</title>
    <link rel="stylesheet" type="text/css" href="<c:url value='/css/add.css'/>">
    <script type="text/javascript" src="${pageContext.request.contextPath }/My97DatePicker/WdatePicker.js"></script>
</head>
<body>
<div class="nav">
    <%
      if(request.getAttribute("error") != null){
    %>
        <div><img src="${pageContext.request.contextPath }/images/add_course_error.jpg"></div>
    <%
      } else{
    %>
        <div><img src="${pageContext.request.contextPath }/images/register_course.jpg"></div>
    <%
      } 
    %>
    <div class="nav1">
        <form action="${pageContext.request.contextPath }/addCourse.do" method="post">
            <p>
                <label for="name">课程名称:</label>
                <input type="text" id="name" name="name" value="">
            </p>
             <p>
                <label for="name">学分:</label>
                <input type="text" id="credit" name="credit" value="">
            </p>
             <p>
              <label for="periodStart">开课日期:</label>
             <input type="text" id="periodStart" name="periodStart" value="" onfocus="WdatePicker({highLineWeekDay:true,isShowToday:true,isShowWeek:true})">
            </p>
             <p>
              <label for="periodEnd">结课日期:</label>
             <input type="text" id="periodEnd" name="periodEnd" value="" onfocus="WdatePicker({highLineWeekDay:true,isShowToday:true,isShowWeek:true})">
            </p>
            <div align="center">
              <input type="submit" value="保存"  />
            </div>
            <div align="center">
        ${error }
            </div>
        </form>
    </div>
</div>
</body>
</html>

addStudent.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>添加学生</title>
    <link rel="stylesheet" type="text/css" href="<c:url value='/css/add.css'/>">
     <script language="javascript" type="text/javascript" src="${pageContext.request.contextPath }/scripts/student.js"></script>
      <script type="text/javascript" src="${pageContext.request.contextPath }/My97DatePicker/WdatePicker.js"></script>
</head>
<body>
<div class="nav">
    <%
      if(request.getAttribute("error") != null){
    %>
        <div><img src="${pageContext.request.contextPath }/images/add_admin_error.jpg"></div>
    <%
      } else{
    %>
        <div><img src="${pageContext.request.contextPath }/images/register_student.jpg"></div>
    <%
      } 
    %>
    <div class="nav1">
        <form action="${pageContext.request.contextPath }/addStudent.do" method="post">
            <p>
                <label for="name">学生姓名:</label>
                <input type="text" id="name" name="name" value=""><span>请输入学生姓名</span>
            </p>
            <p>
                <label for="password">密码:</label>
                <input type="text" id="password" name="password" value=""><span>密码为6-16位</span>
            </p>
            <p>
                <label for="classno">班级:</label>
                <select name="classno" id="classno">
                  <option>--请选择班级--</option>
                  <c:forEach items="${classList }" var="clazz">
                <option>--${clazz.classno}班--</option>
              </c:forEach>
                </select>
               <span style="margin-left: 100px">请输入班级</span>
            </p>
            <p>
                <label>性别:</label>
                <input type="radio" name="sex" value="男" checked="checked" >男
                <input type="radio" name="sex" value="女">女 
            </p>
            <p>
              <label for="tel">关联手机号:</label>
             <input type="text" id="tel" name="tel" value=""><span>请输入手机号</span>
            </p>
             <p>
              <label for="birthday">出生年月日:</label>
             <input type="text" id="birthday" name="birthday" value="" onfocus="WdatePicker({highLineWeekDay:true,isShowToday:true,isShowWeek:true})"><span>请输入出生年月日</span>
            </p>
            <p>
              <label for="remark">评论:</label>
               <select name="remark" id="remark">
                  <option>--请选择--</option>
                  <option>优秀</option>
                  <option>良好</option>
                  <option>合格</option>
                  <option>差劲</option>
                </select>
                <span style="margin-left: 100px">请对该学生进行评论</span>
            </p>
            <button class="sub">
                <img src="${pageContext.request.contextPath }/images/submit.jpg">
            </button>
            <div align="center">
        ${error }
            </div>
        </form>
    </div>
</div>
</body>
</html>

addTeacher.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
  pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加教师</title>
<link rel="stylesheet" type="text/css"
  href="<c:url value='/css/add.css'/>">
<script language="javascript" type="text/javascript"
  src="${pageContext.request.contextPath }/scripts/teacher.js"></script>
<script type="text/javascript"
  src="${pageContext.request.contextPath }/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript"
  src="${pageContext.request.contextPath }/kindeditor/kindeditor-all.js"></script>
<script type="text/javascript"
  src="${pageContext.request.contextPath }/kindeditor/lang/zh_CN.js"></script>
<script>
  KindEditor.ready(function(K) {
    filterMode: false,//是否开启过滤模式
    window.editor = K.create('#remark-id');
  });
</script>
</head>
<body>
  <div class="nav">
    <%
      if (request.getAttribute("error") != null) {
    %>
    <div><img src="${pageContext.request.contextPath }/images/add_teacher_error.jpg"></div>
    <%
      } else {
    %>
    <div><img src="${pageContext.request.contextPath }/images/register_teacher.jpg"></div>
    <%
      }
    %>
    <div class="nav1">
      <form action="${pageContext.request.contextPath }/addTeacher.do"
        method="post">
        <p>
          <label for="name">教师姓名:</label> <input type="text" id="name"
            name="name" value=""><span>请输入教师姓名</span>
        </p>
        <p>
          <label for="password">教师密码:</label> <input type="text"
            id="password" name="password" value=""><span>密码为6-16位</span>
        </p>
        <p>
          <label for="tel">联系方式:</label> <input type="text" id="tel"
            name="tel" value=""><span>请输入手机号</span>
        </p>
        <p>
          <label for="hiredate">入职时间:</label> <input type="text"
            id="hiredate" name="hiredate" value=""
            onfocus="WdatePicker({highLineWeekDay:true,isShowToday:true,isShowWeek:true})"><span>请输入入职时间</span>
        </p>
        <p>
          <label for="remark">评论:</label>
          <textarea class="no" name="remark" id="remark-id"
            style="width: 700px; height: 200px; visibility: hidden; display: block;">
          </textarea>
        </p>
        <button class="sub">
          <img src="${pageContext.request.contextPath }/images/submit.jpg">
        </button>
        <div align="center">${error }</div>
      </form>
    </div>
  </div>
</body>
</html>


四、其他


1.其他系统实现


JavaWeb系统系列实现

Java+JSP实现学生图书管理系统

Java+JSP实现学生信息管理系统

Java+JSP实现用户信息管理系统

Java+Servlet+JSP实现学生成绩管理系统

Java+Servlet+JSP实现宠物诊所管理系统

Java+SSM+Easyui实现网上考试系统

Java+Springboot+H-ui实现营销管理系统

Java+Springboot+Mybatis+Bootstrap实现网上商城系统


JavaSwing系统系列实现

Java+Swing实现斗地主游戏

Java+Swing实现图书管理系统

Java+Swing实现医院管理系统

Java+Swing实现仓库管理系统

Java+Swing实现考试管理系统

Java+Swing实现通讯录管理系统

Java+Swing实现停车场管理系统

Java+Swing实现学生信息管理系统

Java+Swing实现学生宿舍管理系统

Java+Swing实现学生选课管理系统

Java+Swing实现学生成绩管理系统

Java+Swing实现学校教材管理系统

Java+Swing实现学校教务管理系统

Java+Swing实现企业人事管理系统

Java+Swing实现电子相册管理系统

Java+Swing实现自助取款机(ATM)系统

Java+Swing实现超市管理系统-TXT存储信息

Java+Swing实现宠物商店管理系统-TXT存储信息


相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
2月前
|
关系型数据库 MySQL Java
【MySQL+java+jpa】MySQL数据返回项目的感悟
【MySQL+java+jpa】MySQL数据返回项目的感悟
48 1
|
2月前
|
关系型数据库 MySQL Java
【IDEA】java后台操作mysql数据库驱动常见错误解决方案
【IDEA】java后台操作mysql数据库驱动常见错误解决方案
98 0
|
11天前
|
NoSQL Java 关系型数据库
Liunx部署java项目Tomcat、Redis、Mysql教程
本文详细介绍了如何在 Linux 服务器上安装和配置 Tomcat、MySQL 和 Redis,并部署 Java 项目。通过这些步骤,您可以搭建一个高效稳定的 Java 应用运行环境。希望本文能为您在实际操作中提供有价值的参考。
72 26
|
15天前
|
JavaScript 安全 Java
java版药品不良反应智能监测系统源码,采用SpringBoot、Vue、MySQL技术开发
基于B/S架构,采用Java、SpringBoot、Vue、MySQL等技术自主研发的ADR智能监测系统,适用于三甲医院,支持二次开发。该系统能自动监测全院患者药物不良反应,通过移动端和PC端实时反馈,提升用药安全。系统涵盖规则管理、监测报告、系统管理三大模块,确保精准、高效地处理ADR事件。
|
25天前
|
关系型数据库 MySQL Java
MySQL索引优化与Java应用实践
【11月更文挑战第25天】在大数据量和高并发的业务场景下,MySQL数据库的索引优化是提升查询性能的关键。本文将深入探讨MySQL索引的多种类型、优化策略及其在Java应用中的实践,通过历史背景、业务场景、底层原理的介绍,并结合Java示例代码,帮助Java架构师更好地理解并应用这些技术。
25 2
|
1月前
|
监控 前端开发 Java
【技术开发】接口管理平台要用什么技术栈?推荐:Java+Vue3+Docker+MySQL
该文档介绍了基于Java后端和Vue3前端构建的管理系统的技术栈及功能模块,涵盖管理后台的访问、登录、首页概览、API接口管理、接口权限设置、接口监控、计费管理、账号管理、应用管理、数据库配置、站点配置及管理员个人设置等内容,并提供了访问地址及操作指南。
|
2月前
|
SQL Java 关系型数据库
java连接mysql查询数据(基础版,无框架)
【10月更文挑战第12天】该示例展示了如何使用Java通过JDBC连接MySQL数据库并查询数据。首先在项目中引入`mysql-connector-java`依赖,然后通过`JdbcUtil`类中的`main`方法实现数据库连接、执行SQL查询及结果处理,最后关闭相关资源。
142 6
|
1月前
|
SQL XML 缓存
java中jsp详解!!!
JSP(Java Server Pages)是一种动态网页技术标准,允许在HTML页面中嵌入Java代码,实现网页逻辑与设计分离。JSP本质上是Servlet的简化,支持跨平台运行。JSP通过内置对象(如request、response、session等)和指令(如page、include、taglib)提供强大的功能,同时利用EL表达式和JSTL标签库简化页面开发。JSP的核心优势在于快速开发和维护Web应用。
44 0
|
11天前
|
关系型数据库 MySQL 数据库
Python处理数据库:MySQL与SQLite详解 | python小知识
本文详细介绍了如何使用Python操作MySQL和SQLite数据库,包括安装必要的库、连接数据库、执行增删改查等基本操作,适合初学者快速上手。
80 15
|
5天前
|
SQL 关系型数据库 MySQL
数据库数据恢复—Mysql数据库表记录丢失的数据恢复方案
Mysql数据库故障: Mysql数据库表记录丢失。 Mysql数据库故障表现: 1、Mysql数据库表中无任何数据或只有部分数据。 2、客户端无法查询到完整的信息。
下一篇
DataWorks