IDEA+Java+Servlet+JSP+Bootstrap+Mysql实现Web学生成绩管理系统(下)

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

三、部分代码


CourseDaoImpl

package dao.Impl;
import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.List;
import model.Course;
import model.PageBean;
import dao.CourseDao;
import db.DBCon;
public class CourseDaoImpl implements CourseDao {
  private DBCon dbCon = new DBCon();
  private Course course;
  private PageBean pageBean;
  public int addCos(Course course, String courseDate) {
    System.out.println(courseDate);
    // Date courseDate=(Date) course.getCourseDate();
    // DateFormat
    // data=DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM);
    String sql = "insert into course(course_name,course_credit,course_hours,course_teacher,coursedate) values('"
        + course.getCourseName()
        + "',"
        + course.getCourseCredit()
        + ","
        + course.getCourseHours()
        + ",'"
        + course.getCourseTeacher() + "',DATE('" + courseDate + "'))";
    int rs = dbCon.query(sql);
    return rs;
  }
  public int deleteCos(int courseID) {
    String sql = "delete from course where course_id=" + courseID;
    int rs = dbCon.query(sql);
    return rs;
  }
  public int editCos(Course course, String courseDate) {
    String sql = "update course set course_name='" + course.getCourseName()
        + "',course_credit=" + course.getCourseCredit()
        + ",course_hours=" + course.getCourseHours()
        + ",course_teacher='" + course.getCourseTeacher()
        + "',coursedate=DATE('" + courseDate + "') where course_id="
        + course.getCourseID();
    int rs = dbCon.query(sql);
    return rs;
  }
  public List findAll() {
    List<Course> list = new ArrayList<Course>();
    String sql = "select * from course";
    ResultSet rs = dbCon.find(sql);
    try {
      while (rs.next()) {
        int courseID = rs.getInt("course_id");
        String courseName = rs.getString("course_name");
        int courseCredit = rs.getInt("course_credit");
        int courseHours = rs.getInt("course_hours");
        String courseTea = rs.getString("course_teacher");
        Date courseDate = rs.getDate("coursedate");
        course = new Course(courseID, courseName, courseCredit,
            courseHours, courseTea, courseDate);
        list.add(course);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return list;
  }
  public List findOne(int courseID) {
    List<Course> list = new ArrayList<Course>();
    String sql = "select * from course where course_id=" + courseID;
    ResultSet rs = dbCon.find(sql);
    try {
      while (rs.next()) {
        int courseid = rs.getInt("course_id");
        String courseName = rs.getString("course_name");
        int courseCredit = rs.getInt("course_credit");
        int courseHours = rs.getInt("course_hours");
        String courseTea = rs.getString("course_teacher");
        Date courseDate = rs.getDate("coursedate");
        course = new Course(courseid, courseName, courseCredit,
            courseHours, courseTea, courseDate);
        list.add(course);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return list;
  }
  public Course selectOneCos(Course cours) {
    String sql = "select * from course where course_name='"
        + cours.getCourseName() + "' and course_teacher='"
        + cours.getCourseTeacher() + "'";
    ResultSet rs = dbCon.find(sql);
    try {
      while (rs.next()) {
        int courseid = rs.getInt("course_id");
        String courseName = rs.getString("course_name");
        int courseCredit = rs.getInt("course_credit");
        int courseHours = rs.getInt("course_hours");
        String courseTea = rs.getString("course_teacher");
        Date courseDate = rs.getDate("coursedate");
        course = new Course(courseid, courseName, courseCredit,
            courseHours, courseTea, courseDate);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return course;
  }
  public PageBean courseListPage(int pageNo, int pageCount) {
    int totalCount=0;
    List<Course> list = new ArrayList<Course>();
    String sql = "select * from course limit "+((pageNo-1)*pageCount)+","+pageCount;
    String sqlCount="select count(*) from course";
    ResultSet rs = dbCon.find(sql);
    try {
      while (rs.next()) {
        int courseID = rs.getInt("course_id");
        String courseName = rs.getString("course_name");
        int courseCredit = rs.getInt("course_credit");
        int courseHours = rs.getInt("course_hours");
        String courseTea = rs.getString("course_teacher");
        Date courseDate = rs.getDate("coursedate");
        course = new Course(courseID, courseName, courseCredit,
            courseHours, courseTea, courseDate);
        list.add(course);
      }
      rs=dbCon.find(sqlCount);
      while(rs.next()){
        totalCount=rs.getInt(1);
      }
      pageBean=new PageBean(list,totalCount,pageNo,pageCount);
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return pageBean;
  }
}

ScoreDaoImpl

package dao.Impl;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import model.PageBean;
import model.Score;
import model.ScoreCou;
import model.ScoreSum;
import dao.ScoreDao;
import db.DBCon;
public class ScoreDaoImpl implements ScoreDao {
  private Score score = null;
  private ScoreCou scoreCou = null;
  private PageBean pageBean = null;
  private ScoreSum scoreSum = null;
  private DBCon dbCon = new DBCon();
  public int addScore(Score score) {
    String sql = "insert into score(stu_num,stu_name,stu_class,course_name,score_grade,major) values('"
        + score.getStuNum()
        + "','"
        + score.getStuName()
        + "','"
        + score.getStuClass()
        + "','"
        + score.getCourseName()
        + "',"
        + score.getScoreGrade() + ",'" + score.getMajor() + "')";
    int rs = dbCon.query(sql);
    return rs;
  }
  public int deleteScore(int scoreID) {
    String sql = "delete from score where score_id=" + scoreID;
    int rs = dbCon.query(sql);
    return rs;
  }
  public int editCos(Score score) {
    String sql = "update score set stu_num='" + score.getStuNum()
        + "',stu_name='" + score.getStuName() + "',stu_class='"
        + score.getStuClass() + "',course_name='"
        + score.getCourseName() + "',score_grade="
        + score.getScoreGrade() + ",major='" + score.getMajor()
        + "' where score_id=" + score.getScoreID();
    int rs = dbCon.query(sql);
    return rs;
  }
  public List findAll() {
    List<Score> list = new ArrayList<Score>();
    String sql = "select * from score";
    ResultSet rs = dbCon.find(sql);
    try {
      while (rs.next()) {
        int scoreID = rs.getInt("score_id");
        String stuNum = rs.getString("stu_num");
        String stuName = rs.getString("stu_name");
        String stuClass = rs.getString("stu_class");
        String courseName = rs.getString("course_name");
        double scoreGrade = rs.getDouble("score_grade");
        String major = rs.getString("major");
        Score score = new Score(scoreID, stuNum, stuName, stuClass,
            courseName, scoreGrade, major);
        list.add(score);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return list;
  }
  public List findOne(String stuNum) {
    List<ScoreCou> list = new ArrayList<ScoreCou>();
    String sql = "select score.course_name,course_credit,course_hours,course_teacher,major,coursedate,score_grade "
        + "from score,course where score.course_name=course.course_name and stu_num='"
        + stuNum + "'";
    ResultSet rs = dbCon.find(sql);
    try {
      while (rs.next()) {
        String courseName = rs.getString("course_name");
        int courseCredit = rs.getInt("course_credit");
        int courseHours = rs.getInt("course_hours");
        String courseTea = rs.getString("course_teacher");
        String major = rs.getString("major");
        Date courseDate = rs.getDate("coursedate");
        double scoreGrade = rs.getDouble("score_grade");
        ScoreCou scoreCou = new ScoreCou(courseName, courseCredit,
            courseHours, courseTea, major, courseDate, scoreGrade);
        list.add(scoreCou);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return list;
  }
  public List selectScore(int scoreID) {
    List<Score> list = new ArrayList<Score>();
    String sql = "select * from score where score_id=" + scoreID;
    ResultSet rs = dbCon.find(sql);
    try {
      while (rs.next()) {
        int scoreid = rs.getInt("score_id");
        String stuNum = rs.getString("stu_num");
        String stuName = rs.getString("stu_name");
        String stuClass = rs.getString("stu_class");
        String courseName = rs.getString("course_name");
        double scoreGrade = rs.getDouble("score_grade");
        String major = rs.getString("major");
        Score score = new Score(scoreid, stuNum, stuName, stuClass,
            courseName, scoreGrade, major);
        list.add(score);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return list;
  }
  public Score selectScoreInfo(Score scor) {
    String sql = "select * from score where stu_num='" + scor.getStuNum()
        + "' and course_name='" + scor.getCourseName() + "'";
    ResultSet rs = dbCon.find(sql);
    try {
      while (rs.next()) {
        int scoreid = rs.getInt("score_id");
        String stuNum = rs.getString("stu_num");
        String stuName = rs.getString("stu_name");
        String stuClass = rs.getString("stu_class");
        String courseName = rs.getString("course_name");
        double scoreGrade = rs.getDouble("score_grade");
        String major = rs.getString("major");
        score = new Score(scoreid, stuNum, stuName, stuClass,
            courseName, scoreGrade, major);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return score;
  }
  public PageBean scoreListPage(int pageNo, int pageCount, String stuNum) {
    int totalCount = 0;
    List<ScoreCou> list = new ArrayList<ScoreCou>();
    String sql = "select score.course_name,course_credit,course_hours,course_teacher,major,coursedate,score_grade "
        + "from score,course where score.course_name=course.course_name and stu_num='"
        + stuNum
        + "' limit "
        + ((pageNo - 1) * pageCount)
        + ","
        + pageCount;
    String sqlCount = "select count(*) from score,course where score.course_name=course.course_name and stu_num='"
        + stuNum + "'";
    ResultSet rs = dbCon.find(sql);
    try {
      while (rs.next()) {
        String courseName = rs.getString("course_name");
        int courseCredit = rs.getInt("course_credit");
        int courseHours = rs.getInt("course_hours");
        String courseTea = rs.getString("course_teacher");
        String major = rs.getString("major");
        Date courseDate = rs.getDate("coursedate");
        double scoreGrade = rs.getDouble("score_grade");
        ScoreCou scoreCou = new ScoreCou(courseName, courseCredit,
            courseHours, courseTea, major, courseDate, scoreGrade);
        list.add(scoreCou);
      }
      rs = dbCon.find(sqlCount);
      while (rs.next()) {
        totalCount = rs.getInt(1);
      }
      pageBean = new PageBean(list, totalCount, pageNo, pageCount);
    } catch (SQLException e) {
      dbCon.close();
      e.printStackTrace();
    }
    return pageBean;
  }
  public PageBean scoreListPage(int pageNo, int pageCount) {
    int totalCount = 0;
    List<Score> list = new ArrayList<Score>();
    String sql = "select * from score limit " + ((pageNo - 1) * pageCount)
        + "," + pageCount;
    String sqlCount = "select count(*) from score";
    ResultSet rs = dbCon.find(sql);
    try {
      while (rs.next()) {
        int scoreID = rs.getInt("score_id");
        String stuNum = rs.getString("stu_num");
        String stuName = rs.getString("stu_name");
        String stuClass = rs.getString("stu_class");
        String courseName = rs.getString("course_name");
        double scoreGrade = rs.getDouble("score_grade");
        String major = rs.getString("major");
        score = new Score(scoreID, stuNum, stuName, stuClass,
            courseName, scoreGrade, major);
        list.add(score);
      }
      rs = dbCon.find(sqlCount);
      while (rs.next()) {
        totalCount = rs.getInt(1);
      }
      pageBean = new PageBean(list, totalCount, pageNo, pageCount);
    } catch (SQLException e) {
      dbCon.close();
      e.printStackTrace();
    }
    return pageBean;
  }
  public List findStuOne(String stuNum, String courseName) {
    List<ScoreCou> list = new ArrayList<ScoreCou>();
    String sql = "select score.course_name,course_credit,course_hours,course_teacher,major,coursedate,score_grade "
        + "from score,course where score.course_name=course.course_name and stu_num='"
        + stuNum + "' and course.course_name='" + courseName + "'";
    ResultSet rs = dbCon.find(sql);
    try {
      while (rs.next()) {
        String coursename = rs.getString("course_name");
        int courseCredit = rs.getInt("course_credit");
        int courseHours = rs.getInt("course_hours");
        String courseTea = rs.getString("course_teacher");
        String major = rs.getString("major");
        Date courseDate = rs.getDate("coursedate");
        double scoreGrade = rs.getDouble("score_grade");
        scoreCou = new ScoreCou(coursename, courseCredit, courseHours,
            courseTea, major, courseDate, scoreGrade);
        list.add(scoreCou);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return list;
  }
  public PageBean selectScoreSum(int pageNo, int pageCount) {
    int totalCount = 0;
    int i = 1;
    List<ScoreSum> list = new ArrayList<ScoreSum>();
    String sql = "select score.stu_num,score.stu_name,score.stu_class,score.major, sum(score.score_grade) as total,avg(score.score_grade) as avg "
        + "from score group by score.stu_num order by total DESC limit "
        + ((pageNo - 1) * pageCount) + "," + pageCount;
    String sqlCount = "select count(*) from (select stu_num from score group by score.stu_num ) as a";
    ResultSet rs = dbCon.find(sql);
    try {
      while (rs.next()) {
        int number = i;
        String stuNum = rs.getString("stu_num");
        String stuName = rs.getString("stu_name");
        String stuClass = rs.getString("stu_class");
        String major = rs.getString("major");
        double total = rs.getDouble("total");
        double avg = rs.getDouble("avg");
        scoreSum = new ScoreSum(number, stuNum, stuName, stuClass,
            major, total, avg);
        list.add(scoreSum);
        i++;
      }
      rs = dbCon.find(sqlCount);
      while (rs.next()) {
        totalCount = rs.getInt(1);
      }
      pageBean = new PageBean(list, totalCount, pageNo, pageCount);
    } catch (SQLException e) {
      dbCon.close();
      e.printStackTrace();
    }
    return pageBean;
  }
  public PageBean selectStuScore(int pageNo, int pageCount, Score score) {
    int totalCount = 0;
    List<Score> list = new ArrayList<Score>();
    String sql = "select * from score where stu_num like '%"
        + score.getStuNum() + "%' and course_name like '%"
        + score.getCourseName() + "%' and stu_name like '%"
        + score.getStuName() + "%' and stu_class like '%"
        + score.getStuClass() + "%' and major like '%"
        + score.getMajor() + "%' limit " + ((pageNo - 1) * pageCount)
        + "," + pageCount;
    String sqlCount = "select count(*) from score where stu_num like '%"
        + score.getStuNum() + "%' and course_name like '%"
        + score.getCourseName() + "%' and stu_name like '%"
        + score.getStuName() + "%' and stu_class like '%"
        + score.getStuClass() + "%' and major like '%"
        + score.getMajor() + "%'";
    ResultSet rs = dbCon.find(sql);
    try {
      while (rs.next()) {
        int scoreID = rs.getInt("score_id");
        String stuNum = rs.getString("stu_num");
        String stuName = rs.getString("stu_name");
        String stuClass = rs.getString("stu_class");
        String courseName = rs.getString("course_name");
        double scoreGrade = rs.getDouble("score_grade");
        String major = rs.getString("major");
        score = new Score(scoreID, stuNum, stuName, stuClass,
            courseName, scoreGrade, major);
        list.add(score);
      }
      rs = dbCon.find(sqlCount);
      while (rs.next()) {
        totalCount = rs.getInt(1);
      }
      pageBean = new PageBean(list, totalCount, pageNo, pageCount);
    } catch (SQLException e) {
      dbCon.close();
      e.printStackTrace();
    }
    return pageBean;
  }
  public PageBean selectTeaScore(int pageNo, int pageCount, String teaName,
      Score score) {
    int totalCount = 0;
    List<Score> list = new ArrayList<Score>();
    String sql = "select score.score_id,score.stu_num,score.stu_name,score.stu_class,score.course_name,score.score_grade,score.major from score,course where score.course_name=course.course_name and course.course_teacher='"
        + teaName
        + "'  and score.stu_name like '%"
        + score.getStuName()
        + "%' and score.stu_class like '%"
        + score.getStuClass()
        + "%' and score.stu_num like '%"
        + score.getStuNum()
        + "%' limit "
        + ((pageNo - 1) * pageCount)
        + "," + pageCount;
    String sqlCount = "select count(*) from score,course where score.course_name=course.course_name and course.course_teacher='"
        + teaName 
        + "'  and score.stu_name like '%"
        + score.getStuName()
        + "%' and score.stu_class like '%"
        + score.getStuClass()
        + "%' and score.stu_num like '%"
        + score.getStuNum()
        + "'";
    ResultSet rs = dbCon.find(sql);
    try {
      while (rs.next()) {
        int scoreID = rs.getInt("score_id");
        String stuNum = rs.getString("stu_num");
        String stuName = rs.getString("stu_name");
        String stuClass = rs.getString("stu_class");
        String courseName = rs.getString("course_name");
        double scoreGrade = rs.getDouble("score_grade");
        String major = rs.getString("major");
        score = new Score(scoreID, stuNum, stuName, stuClass,
            courseName, scoreGrade, major);
        list.add(score);
      }
      rs = dbCon.find(sqlCount);
      while (rs.next()) {
        totalCount = rs.getInt(1);
      }
      pageBean = new PageBean(list, totalCount, pageNo, pageCount);
    } catch (SQLException e) {
      dbCon.close();
      e.printStackTrace();
    }
    return pageBean;
  }
}

StudentDaoImpl

package dao.Impl;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import model.PageBean;
import model.Student;
import dao.StudentDao;
import db.DBCon;
public class StudentDaoImpl implements StudentDao {
  private DBCon dbCon = new DBCon();
  private Student student;
  private PageBean pageBean;
  public int addStu(Student student) {
    String sql = "insert into student(stu_num,stu_name,stu_sex,stu_age,stu_class,major,department) values('"
        + student.getStuNum()
        + "','"
        + student.getStuName()
        + "','"
        + student.getStuSex()
        + "',"
        + student.getStuAge()
        + ",'"
        + student.getStuClass()
        + "','"
        + student.getMajor()
        + "','"
        + student.getDepartment() + "')";
    int rs = dbCon.query(sql);
    return rs;
  }
  public int deleteStu(String stuNum) {
    String sql = "delete from student where stu_num='" + stuNum + "'";
    int rs = dbCon.query(sql);
    return rs;
  }
  public int editStu(Student student) {
    String sql = "update student set stu_name='" + student.getStuName()
        + "',stu_sex='" + student.getStuSex() + "',stu_age="
        + student.getStuAge() + ",stu_class='" + student.getStuClass()
        + "',major='" + student.getMajor() + "',department='"
        + student.getDepartment() + "' where stu_num='"
        + student.getStuNum() + "'";
    int rs=dbCon.query(sql);
    return rs;
  }
  public List findAll() {
    List<Student> list = new ArrayList<Student>();
    String sql = "select * from student";
    ResultSet rs = dbCon.find(sql);
    try {
      while (rs.next()) {
        int stuID = rs.getInt("stu_id");
        String stuNum = rs.getString("stu_num");
        String stuName = rs.getString("stu_name");
        String stuSex = rs.getString("stu_sex");
        int stuAge = rs.getInt("stu_age");
        String stuClass = rs.getString("stu_class");
        String major = rs.getString("major");
        String department = rs.getString("department");
        student = new Student(stuID, stuNum, stuName, stuSex, stuAge,
            stuClass, major, department);
        list.add(student);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return list;
  }
  public List findOne(String stuNum) {
    List<Student> list = new ArrayList<Student>();
    String sql="select * from student where stu_num='"+stuNum+"'";
    ResultSet rs=dbCon.find(sql);
    try {
      while(rs.next()){
        int stuID = rs.getInt("stu_id");
        String stunum = rs.getString("stu_num");
        String stuName = rs.getString("stu_name");
        String stuSex = rs.getString("stu_sex");
        int stuAge = rs.getInt("stu_age");
        String stuClass = rs.getString("stu_class");
        String major = rs.getString("major");
        String department = rs.getString("department");
        student = new Student(stuID, stunum, stuName, stuSex, stuAge,
            stuClass, major, department);
        list.add(student);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return list;
  }
  //pageNo当前页码,pageCount每页显示总条数
  public PageBean stuListPage(int pageNo, int pageCount) {
    int totalCount=0;
    List<Student> list = new ArrayList<Student>();
    String sql="select * from student limit "+((pageNo-1)*pageCount)+","+pageCount;
    String sqlCount="select count(*) from student";
    try {
      ResultSet rs=dbCon.find(sql);
      while(rs.next()){
        int stuID = rs.getInt("stu_id");
        String stuNum = rs.getString("stu_num");
        String stuName = rs.getString("stu_name");
        String stuSex = rs.getString("stu_sex");
        int stuAge = rs.getInt("stu_age");
        String stuClass = rs.getString("stu_class");
        String major = rs.getString("major");
        String department = rs.getString("department");
        student = new Student(stuID, stuNum, stuName, stuSex, stuAge,
            stuClass, major, department);
        list.add(student);
      }
      rs=dbCon.find(sqlCount);
      while(rs.next()){
        totalCount=rs.getInt(1); 
      }
      pageBean=new PageBean(list ,  totalCount,  pageNo,  pageCount);
    } catch (SQLException e) {
      dbCon.close();
      e.printStackTrace();
    }
    return pageBean;
  }
}

TeacherDaoImpl

package dao.Impl;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import model.PageBean;
import model.Student;
import model.Teacher;
import dao.TeacherDao;
import db.DBCon;
public class TeacherDaoImpl implements TeacherDao{
  private DBCon dbCon = new DBCon();
  private Teacher teacher;
  private PageBean pageBean;
  public int addTea(Teacher teacher) {
    String sql = "insert into teacher(tea_num,tea_name,tea_sex,tea_age,tea_course,major,department) values('"
        + teacher.getTeaNum()
        + "','"
        + teacher.getTeaName()
        + "','"
        + teacher.getTeaSex()
        + "',"
        + teacher.getTeaAge()
        + ",'"
        + teacher.getTeaCourse()
        + "','"
        + teacher.getMajor()
        + "','"
        + teacher.getDepartment() + "')";
    int rs = dbCon.query(sql);
    return rs;
  }
  public int deleteTea(String teaNum) {
    String sql = "delete from teacher where tea_num='" + teaNum + "'";
    int rs = dbCon.query(sql);
    return rs;
  }
  public int editTea(Teacher teacher) {
    String sql = "update teacher set tea_name='" + teacher.getTeaName()
        + "',tea_sex='" + teacher.getTeaSex() + "',tea_age="
        + teacher.getTeaAge() + ",tea_course='" + teacher.getTeaCourse()
        + "',major='" + teacher.getMajor() + "',department='"
        + teacher.getDepartment() + "' where tea_num='"
        + teacher.getTeaNum() + "'";
    int rs=dbCon.query(sql);
    return rs;
  }
  public List findAll() {
    List<Teacher> list=new ArrayList<Teacher>();
    String sql="select * from teacher";
    ResultSet rs=dbCon.find(sql);
    try {
      while (rs.next()) {
        int teaID = rs.getInt("tea_id");
        String teaNum = rs.getString("tea_num");
        String teaName = rs.getString("tea_name");
        String teaSex = rs.getString("tea_sex");
        int teaAge = rs.getInt("tea_age");
        String teaCourse = rs.getString("tea_course");
        String major = rs.getString("major");
        String department = rs.getString("department");
        teacher = new Teacher(teaID, teaNum, teaName, teaSex, teaAge,
            teaCourse, major, department);
        list.add(teacher);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return list;
  }
  public List findOne(String teaNum) {
    List<Teacher> list=new ArrayList<Teacher>();
    String sql="select * from teacher where tea_num='"+teaNum+"'";
    ResultSet rs=dbCon.find(sql);
    try {
      while (rs.next()) {
        int teaID = rs.getInt("tea_id");
        String teanum = rs.getString("tea_num");
        String teaName = rs.getString("tea_name");
        String teaSex = rs.getString("tea_sex");
        int teaAge = rs.getInt("tea_age");
        String teaCourse = rs.getString("tea_course");
        String major = rs.getString("major");
        String department = rs.getString("department");
        teacher = new Teacher(teaID, teanum, teaName, teaSex, teaAge,
            teaCourse, major, department);
        list.add(teacher);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return list;
  }
  public PageBean teaListPage(int pageNo, int pageCount) {
    List<Teacher> list=new ArrayList<Teacher>();
    int totalCount=0;
    String sql="select * from teacher limit "+((pageNo-1)*totalCount)+","+totalCount;
    String sqlCount="select count(*) from teacher";
    ResultSet rs=dbCon.find(sql);
    try {
      while(rs.next()){
        int teaID = rs.getInt("tea_id");
        String teanum = rs.getString("tea_num");
        String teaName = rs.getString("tea_name");
        String teaSex = rs.getString("tea_sex");
        int teaAge = rs.getInt("tea_age");
        String teaCourse = rs.getString("tea_course");
        String major = rs.getString("major");
        String department = rs.getString("department");
        teacher = new Teacher(teaID, teanum, teaName, teaSex, teaAge,
            teaCourse, major, department);
        list.add(teacher);
      }
      rs=dbCon.find(sqlCount);
      while(rs.next()){
        totalCount=rs.getInt(1);
      }
    } catch (SQLException e) {
      dbCon.close();
      e.printStackTrace();
    }
    pageBean=new PageBean(list,totalCount,pageNo,pageCount);
    return pageBean;
  }
}

UserDaoImpl

package dao.Impl;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import model.UsRole;
import model.User;
import dao.UserDao;
import db.DBCon;
public class UserDaoImpl implements UserDao {
  private DBCon dbCon = new DBCon();
  private User user;
  private UsRole usRole;
  public User login(User user) {
    String sql = "select *from user where user_num='" + user.getUserNum()
        + "'";
    ResultSet rs = dbCon.find(sql);
    try {
      while (rs.next()) {
        int userID = rs.getInt("user_id");
        String userNum = rs.getString("user_num");
        String userName = rs.getString("user_name");
        String pwd = rs.getString("password");
        String phone = rs.getString("phone");
        int roleID = rs.getInt("role_id");
        user = new User(userID, userNum, userName, pwd, phone, roleID);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return user;
  }
  public int editPwd(User user) {
    String sql = "update user set password='" + user.getPassword()
        + "' where user_num='" + user.getUserNum() + "'";
    int rs = dbCon.query(sql);
    return rs;
  }
  public int addUser(User user) {
    String sql = "insert into user(user_num,user_name,password,phone,role_id) values('"
        + user.getUserNum()
        + "','"
        + user.getUserName()
        + "','"
        + user.getPassword()
        + "',"
        + user.getPhone()
        + ","
        + user.getRoleID() + ")";
    int rs = dbCon.query(sql);
    return rs;
  }
  public List findAll() {
    List<UsRole> list = new ArrayList<UsRole>();
    String sql = "select user_id,user_num,user_name,password,phone,role_name from user,role where user.role_id=role.role_id";
    ResultSet rs = dbCon.find(sql);
    try {
      while (rs.next()) {
        int userID = rs.getInt("user_id");
        String userNum = rs.getString("user_num");
        String userName = rs.getString("user_name");
        String pwd = rs.getString("password");
        String phone = rs.getString("phone");
        String roleName = rs.getString("role_name");
        usRole = new UsRole(userID, userNum, userName, pwd, phone,
            roleName);
        list.add(usRole);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return list;
  }
  public List selectOneUser(int userID) {
    List<User> list = new ArrayList<User>();
    String sql = "select * from user where user_id=" + userID;
    ResultSet rs = dbCon.find(sql);
    try {
      while (rs.next()) {
        int userid = rs.getInt("user_id");
        String userNum = rs.getString("user_num");
        String userName = rs.getString("user_name");
        String pwd = rs.getString("password");
        String phone = rs.getString("phone");
        int roleID = rs.getInt("role_id");
        user = new User(userID, userNum, userName, pwd, phone, roleID);
        list.add(user);
      }
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return list;
  }
  public int editUser(User user) {
    String sql = "update user set user_name='" + user.getUserName()
        + "',password=" + user.getPassword() + ",phone='"
        + user.getPhone() + "' where user_num='" + user.getUserNum()
        + "'";
    int rs = dbCon.query(sql);
    return rs;
  }
}

DBCon

package db;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
public class DBCon {
  Connection con = null;
  Statement st = null;
  ResultSet rs = null;
  String driver=null;
  String url = null;
  String username = null;
  String password = null;
  public Connection dbCon() {
    try {
      InputStream is=DBCon.class.getClassLoader().getResourceAsStream("db.properties");
      Properties prop=new Properties();
      try {
        prop.load(is);
        driver=prop.getProperty("driver");
        url=prop.getProperty("url");
        username=prop.getProperty("username");
        password=prop.getProperty("password");
      } catch (IOException e1) {
        e1.printStackTrace();
      }
      Class.forName(driver);
      /*Class.forName("com.mysql.jdbc.Driver");
      url = "jdbc:mysql:///sams?useUnicode=true&characterEncoding=utf8";
      username = "root";
      password = "root";*/
      try {
        con = DriverManager.getConnection(url, username, password);
      } catch (SQLException e) {
        e.printStackTrace();
      }
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }
    return con;
  }
  /*
   * 增删改
   */
  public int query(String sql) {
    int rs = 0;
    con = dbCon();
    try {
      st = con.createStatement();
      rs = st.executeUpdate(sql);
    } catch (SQLException e) {
      close();
      e.printStackTrace();
    }
    return rs;
  }
  /*
   * 查
   */
  public ResultSet find(String sql) {
    try {
      con = dbCon();
      st = con.createStatement();
      rs = st.executeQuery(sql);
    } catch (SQLException e) {
      close();
      e.printStackTrace();
    }
    return rs;
  }
  /*
   * 关闭数据库
   */
  public void close() {
    try {
      if (rs != null)
        rs.close();
      if (st != null)
        st.close();
      if (con != null)
        con.close();
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
}

register.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>注册页面</title>
  <meta http-equiv="pragma" content="no-cache">
  <meta http-equiv="cache-control" content="no-cache">
  <meta http-equiv="expires" content="0">    
  <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
  <meta http-equiv="description" content="This is my page">
  </head>
  <style type="text/css">
    html, body {
        margin: 0;
        padding: 0;
        width: 100%;
        height: 100%;
        background-image: linear-gradient(to bottom, #243949 0%, #517fa4 100%);
        overflow: hidden;
      }
    canvas{
      position: absolute;
      top: 0;
    }
    .div_ads {
      z-index: 3;
      width: 30%;
      margin: 0 auto;
      margin-top: 50px;
      border: 1px solid #ccc;
      background: rgba(238, 235, 235,1);
      position: relative;
      border-radius: 6px;
      height: 650px;
    }
    table {
      position: absolute;
      left: 10%;
    }
    table tr td {
      text-align: center;
      height:44px;
      width: 8%;
      text-align: center;
    }
    h3{
      text-align: center;
      padding-top: 20px;
    }
    hr{
      margin-left: 15px;
      margin-right: 15px;
      background: #ccc;
    }
    .btn1{
      background: #afc5d6;
    }
    font{
      font-size: .7rem;
      float: left;
    }
  </style>
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/particle-bg.umd.min.js"></script>
<script type="text/javascript">
window.onload = function(){
  particleBg('body', {
      color: 'rgba(255, 255, 255, 0.5)'
    });
}
</script>
<script type="text/javascript">
  function AjaxChecked(){
    var xmlHttpRequest=null;
    if(XMLHttpRequest){
      xmlHttpRequest=new XMLHttpRequest();
    }else{
      xmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP");
    }
    if(xmlHttpRequest!=null){
      //拿到账号
      var stuNum=document.getElementById("stuNum");
      if(stuNum.value==""){
        document.getElementById("stuNumcheck").innerHTML = "学号不能为空";
        return;
      }else{
        var url="ServletRegisterStu?stuNum="+stuNum.value;
        xmlHttpRequest.open("get",url,true);
        xmlHttpRequest.send();
        xmlHttpRequest.onreadystatechange=function(){
          if(xmlHttpRequest.readyState==4 && xmlHttpRequest.status==200){
            var text = xmlHttpRequest.responseText;
            //alert(text);
            document.getElementById("stuNumcheck").innerHTML = text;
          }
        };
      }
    }
  }
  function namecheck(){
    var stuName=document.getElementById("stuName").value;
    var rename=/^[\u4e00-\u9fa5]+$/gi;          //中文判断
    if(stuName==""){
      document.getElementById("stuNamecheck").innerHTML = "用户名不能为空";
    }
    else if (!rename.test(stuName))
    {
      document.getElementById("stuNamecheck").innerHTML = "请输入中文名,如:王文军";
    }else{
      document.getElementById("stuNamecheck").innerHTML = "正确";
    }
  }
  function pwdcheck(){
    var pwd1=document.getElementById("password").value;
    if(pwd1==""){
      document.getElementById("stuPwdcheck").innerHTML = "密码不能为空";
    }else if(pwd1.length<6){
      document.getElementById("stuPwdcheck").innerHTML = "密码不能小于六位";
    }else {
      document.getElementById("stuPwdcheck").innerHTML = "正确";
    }
  }
  function pwdc(){
    var pwd1=document.getElementById("password").value;
    var pwd2=document.getElementById("pwd").value;
    if(pwd1==""){
      document.getElementById("stuPwdrcheck").innerHTML = "确认密码不能为空";
    }else if(pwd1!=pwd2){
      document.getElementById("stuPwdrcheck").innerHTML = "两次密码不一致";
    }else {
      document.getElementById("stuPwdrcheck").innerHTML = "正确";
    }
  }
</script>
</head>
<body>
   <form action="ServletRegistersStudent" method="post"> 
    <div class="div_ads">
    <font>${msg}</font><h3>注册页面</h3>
    <hr class="color:black">
      <table>
        <tr>
          <td colspan="2"><input type="text" name="stuNum" class="put form-control" id="stuNum" onblur="AjaxChecked();" placeholder="学号" aria-describedby="basic-addon1"/></td>
          <td><font id="stuNumcheck"></font></td>
        </tr>
        <tr>
          <td colspan="2"><input type="text" name="stuName" class="put form-control" id="stuName" onblur="namecheck();" placeholder="姓名" aria-describedby="basic-addon1"/></td>
          <td><font id="stuNamecheck"></font></td>
        </tr>
        <tr>
          <td colspan="2"><input type="password" name="password" class="put form-control" id="password" onblur="pwdcheck();"  placeholder="密码" aria-describedby="basic-addon1"/></td>
          <td><font id="stuPwdcheck"></font></td>
        </tr>
        <tr>
          <td colspan="2"><input type="password" name="pwd" class="put form-control" id="pwd" onblur="pwdc();"  placeholder="确认密码" aria-describedby="basic-addon1"/></td>
          <td><font id="stuPwdrcheck"></font></td>
        </tr>
        <tr>
          <td colspan="2"><input type="radio"  name="stuSex" value="男" checked="checked" />男&nbsp;&nbsp;
            <input type="radio" name="stuSex" value="女" />女
          </td>
        </tr>
        <tr>
          <td colspan="2"><input type="text" name="stuAge" class="put form-control" placeholder="年龄" aria-describedby="basic-addon1"/></td>
        </tr>
        <tr>
          <td colspan="2"><input type="text" name="stuClass" class="put form-control" placeholder="班级" aria-describedby="basic-addon1"/></td>
        </tr>
        <tr>
          <td colspan="2"><input type="text" name="major" class="put form-control" placeholder="专业" aria-describedby="basic-addon1"/></td>
        </tr>
        <tr>
          <td colspan="2"><input type="text" name="department" class="put form-control" placeholder="院系" aria-describedby="basic-addon1"/></td>
        </tr>
        <tr>
          <td colspan="2"><input type="text" name="phone" class="put form-control" placeholder="电话" aria-describedby="basic-addon1"/></td>
        </tr>
        <tr>
          <td colspan="2"><input type="hidden" name="role" value="0" /></td>
        </tr>
        <tr>
          <td><input type="submit" value="注册" class="putb btn btn1" /></td>
          <td><input type="reset" value="清空" class="putb btn btn1" /></td>
        </tr>
      </table>
    </div>
   </form> 
</body>
</html>

login.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>登陆</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<style type="text/css">
html, body {
      margin: 0;
      padding: 0;
      width: 100%;
      height: 100%;
      background-image: linear-gradient(to bottom, #243949 0%, #517fa4 100%);
      overflow: hidden;
    }
canvas{
  position: absolute;
  top: 0;
  z-index: -1;
}
#_top {
  text-align: center;
  height: 100px;
  font-size: 30px;
  padding-top: 30px;
  letter-spacing: 10px; /*字与字之间的间距*/
}
#_top span{
  color: aliceblue;
}
.div_body {
  height: 400px;
  width: 30%;
  margin: 10% auto;
  position: relative;
  /*background:rgba(255,255,255, 0.3);*/
  background: #fff;
  /*box-shadow: whitesmoke 5px 5px 50px 5px;*/
  border-radius: 6px;
  z-index: 2;
}
#_body {
  width: 100%;
  text-align: center;
}
.msg{
  padding-top: 20px;
  color: #374b5d;
  height: 40px;
}
table{
  margin: 0 10%;
  width: 100%;
  height: 85%;
}
table tr{
  width: 100%;
  height: 15%;
}
table tr td{
  font-size: 20px;
  width: 100%;
}
.input{
  width: 80%;
  height: 55%;
  border-radius: 10px;
  text-align: center;
  font-size: 15px;
  border:1px solid #ccc;
  color: #ccc;
}
.btn {
    color: #ffffff;
    background-color: #40586d;
    border-color: #374b5d;
    width:20%;
    margin-right: 8%;
}
.check{
  width: 13%;
}
</style>
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/particle-bg.umd.min.js"></script>
<script type="text/javaScript">
window.onload = function() {
  particleBg('body', {
    color: 'rgba(255, 255, 255, 0.5)'
  });
}
</script>
</head>
<body>
  <div class="div_body">
    <div id="_body">
    <h3 class="msg" style="cursor:default">${massage }</h3>
      <form action="ServletLogin" method="post"
        onsubmit="return checked(this)">
        <table>
          <tr>
            <td><input class="input" type="text" name="ID" placeholder="账号">
            </td>
          </tr>
          <tr>
            <td><input class="input" type="password" name="pwd" placeholder="密码">
            </td>
          </tr>
          <tr>
            <td>
              <input class="check" type="radio" name="role" value="0" checked="checked">学生
              <input class="check" type="radio" name="role" value="1">教师 
              <input class="check" type="radio" name="role" value="2">管理员
            </td>
          </tr>
          <tr>
            <td>
              <input class="btn" type="submit" value="登录">
              <input class="btn" type="button" name="register" value="注册"
              onclick="window.open('register/register.jsp')">
              <input class="btn" type="reset" value="取消">
            </td>
          </tr>
        </table>
      </form>
    </div>
  </div>
</body>
</html>

selectScore.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title></title>
  <meta http-equiv="pragma" content="no-cache">
  <meta http-equiv="cache-control" content="no-cache">
  <meta http-equiv="expires" content="0">    
  <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
  <meta http-equiv="description" content="This is my page">
<style type="text/css">
.div_select,.div_ads {
  width:75%;
  margin: auto;
  margin-top: 50px;
  margin-left:20%;
}
.attr{
  font:bold;
}
a{
  cursor: pointer
}
#form1{
width:200px;
display: inline-block
}
#pageNo{
width:200px;
display: inline-block
}
</style>
<link rel="stylesheet" href="css/bootstrap.min.css">
<script type="text/javascript">
  function page(s){
    var frm=document.getElementById("frm");
    var pageNo=document.getElementById("pageNo");
    pageNo.value=s;
    frm.submit();
  }
  </script>
  </head>
<body>
    <div class="div_select">
        <form action="ServletOneStudentScore" method="post">
        课程名:<input type="text" class="form-control" id="form1"  name="cosName"/> <input type="submit" class="btn btn-primary" value="查询" />
        </form>
      </div>
      <form action="ServletFindStudentScore" method="post" id="frm"></form>
    <div class="div_ads">
        <div class="panel panel-default">
            <!-- Default panel contents -->
            <div class="panel-heading">
              成绩信息
            </div>
            <!-- Table -->
            <table class="table" style="width: 100%">
              <tr>
                <td><b>科目</b></td>
                <td><b>学分</b></td>
                <td><b>学时</b></td>
                <td><b>任课教师</b></td>
                <td><b>专业</b></td>
                <td><b>开课时间</b></td>
                <td><b>成绩</b></td>
              </tr>
              <c:forEach var="list" items="${list.pbjs }">
                <tr>
                    <td>${list.getCourseName() }</td>
                    <td>${list.getCourseCredit() }</td>
                    <td>${list.getCourseHours() }</td>
                    <td>${list.getCourseTeacher() }</td>
                    <td>${list.getMajor() }</td>
                    <td>${list.getCourseDate() }</td>
                    <td>${list.getScoreGrade() }</td>
                </tr>
                </c:forEach>
              <tr>
              <td colspan="7"><a onclick="page(1);">首页</a> 
              <c:if test="${list.isPrevious() }"> 
                <a onclick="page(${list.pageNo-1});">上一页</a>
              </c:if> 
              <c:if test="${list.isNext() }">
                <a onclick="page(${list.pageNo+1});">下一页</a>
              </c:if> 
              <a onclick="page(${list.totalPage });">最后一页</a> <br />
               跳转到:<input id="pageNo" type="text"  class="form-control form1"  name="pageNo" value="${list.pageNo }" />
              每页记录数:<input type="text" name="pageCount"  class="form-control" id="form1"  value="${list.pageCount }" /> 
              <input type="hidden" name="totalPage" value="${list.totalPage }" id='form1' /> 
              <input type="submit" class="btn btn-primary" value="跳转" /> 共有${list.totalPage }页</td>
            </tr>
            </table>
            </div>
    </div>
  </form>
<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

四、其他


1.其他系统实现


1.JavaWeb系统系列实现

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


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


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


Java+Servlet+JSP实现航空订票系统


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


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


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


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


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


2.JavaSwing系统系列实现

Java+Swing实现斗地主游戏


Java+Swing实现图书管理系统


Java+Swing实现医院管理系统


Java+Swing实现仓库管理系统-1


Java+Swing实现仓库管理系统-2


Java+Swing实现考试管理系统


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


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


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


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


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


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


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


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


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


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


Java+Swing实现超市管理系统-TXT存储数据


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
相关文章
|
19天前
|
Java 开发者 微服务
Spring Boot 入门:简化 Java Web 开发的强大工具
Spring Boot 是一个开源的 Java 基础框架,用于创建独立、生产级别的基于Spring框架的应用程序。它旨在简化Spring应用的初始搭建以及开发过程。
38 6
Spring Boot 入门:简化 Java Web 开发的强大工具
|
1月前
|
Java Maven Spring
Java Web 应用中,资源文件的位置和加载方式
在Java Web应用中,资源文件如配置文件、静态文件等通常放置在特定目录下,如WEB-INF或classes。通过类加载器或Servlet上下文路径可实现资源的加载与访问。正确管理资源位置与加载方式对应用的稳定性和可维护性至关重要。
54 6
|
1月前
|
Java 持续交付 项目管理
使用Maven进行项目管理:提高Java Web开发的效率
Maven 是一款强大的项目管理和构建自动化工具,广泛应用于Java社区。它通过依赖管理、构建生命周期管理、插件机制和多模块项目支持等功能,简化了项目的构建过程,提高了开发效率。本文将介绍Maven的核心功能及其在Java Web开发中的应用。
65 0
|
2月前
|
Java 容器
【学习笔记】Jsp与Servlet技术
【学习笔记】Jsp与Servlet技术
82 0
|
4月前
|
SQL Java 数据库
jsp中使用Servlet查询SQLSERVER数据库中的表的信息,并且打印在屏幕上
该博客文章介绍了在JSP应用中使用Servlet查询SQL Server数据库的表信息,并通过JavaBean封装图书信息,将查询结果展示在Web页面上的方法。
jsp中使用Servlet查询SQLSERVER数据库中的表的信息,并且打印在屏幕上
|
4月前
|
供应链 前端开发 Java
JSP+servlet+mybatis+layui服装库存管理系统(大三上学期课程设计)
这篇文章通过一个服装库存管理系统的实例,展示了在Spring Boot项目中使用Ajax、JSON、layui、MVC架构和iframe等技术,涵盖了注册登录、权限管理、用户管理、库存管理等功能,并提供了系统运行环境和技术要求的详细说明。
JSP+servlet+mybatis+layui服装库存管理系统(大三上学期课程设计)
|
4月前
|
前端开发 安全 Java
在Java服务器端开发的浩瀚宇宙中,Servlet与JSP犹如两颗璀璨的明星,它们联袂登场,共同编织出动态网站的绚丽篇章。
在Java服务器端开发的浩瀚宇宙中,Servlet与JSP犹如两颗璀璨的明星,它们联袂登场,共同编织出动态网站的绚丽篇章。
31 0
|
6月前
|
自然语言处理 前端开发 Java
Servlet与JSP:Java Web开发的基石技术详解
【6月更文挑战第23天】Java Web的Servlet与JSP是动态网页的核心。Servlet是服务器端的Java应用,处理HTTP请求并响应;JSP则是结合HTML与Java代码的页面,用于动态内容生成。Servlet通过生命周期方法如`init()`、`service()`和`destroy()`工作,而JSP在执行时编译成Servlet。两者在MVC架构中分工,Servlet处理逻辑,JSP展示数据。尽管有Spring MVC等框架,Servlet和JSP仍是理解Web开发基础的关键。
114 12
|
6月前
|
存储 Java 关系型数据库
基于Servlet和JSP的Java Web应用开发指南
【6月更文挑战第23天】构建Java Web应用,Servlet与JSP携手打造在线图书管理系统,涵盖需求分析、设计、编码到测试。通过实例展示了Servlet如何处理用户登录(如`LoginServlet`),JSP负责页面展示(如`login.jsp`和`bookList.jsp`)。应用基于MySQL数据库,包含用户和图书表。登录失败显示错误信息,成功后展示图书列表。部署到Tomcat服务器测试功能。此基础教程为深入Java Web开发奠定了基础。
131 10
|
6月前
|
缓存 小程序 前端开发
Java服务器端技术探秘:Servlet与JSP的核心原理
【6月更文挑战第23天】Java Web开发中的Servlet和JSP详解:Servlet是服务器端的Java小程序,处理HTTP请求并响应。生命周期含初始化、服务和销毁。创建Servlet示例代码展示了`doGet()`方法的覆盖。JSP则侧重视图,动态HTML生成,通过JSP脚本元素、声明和表达式嵌入Java代码。Servlet常作为控制器,JSP处理视图,遵循MVC模式。优化策略涉及缓存、分页和安全措施。这些技术是Java服务器端开发的基础。
69 9
下一篇
DataWorks