JSP——分页查询

news2025/1/18 10:52:14

在这里插入图片描述

✅作者简介:热爱国学的Java后端开发者,修心和技术同步精进。
🍎个人主页:Java Fans的博客
🍊个人信条:不迁怒,不贰过。小知识,大智慧。
💞当前专栏:JAVA开发者成长之路
✨特色专栏:国学周更-心性养成之路
🥭本文内容:JSP——分页查询
更多内容点击👇
      JSP——标准标签库 (JSTL)

文章目录

    • 1.1 概念
    • 1.2 分页实现思路
    • 1.3 分页代码实现步骤
      • 1.3.1 数据库准备
      • 1.3.2 数据库配置文件
      • 1.3.3 创建实体类
      • 1.3.4 创建StudentDao接口
      • 1.3.5 StudentDaoImpl实现类
      • 1.3.6 创建StudentService接口
      • 1.3.7 StudentServiceImpl实现类
      • 1.3.8 studentShow0.jsp
      • 1.3.9 运行效果图部分截图

在这里插入图片描述

1.1 概念

  分页是Web应用程序非常重要的一个技术。数据库中的数据可能是成千上万的,不可能把这么多的数据一次显示在浏览器上面。一般根据每行数据在页面上所占的空间设置每页显示若干行,比如一般20行是一个比较理想的显示状态。

1.2 分页实现思路

  对于海量的数据查询,需多少就取多少,显然是最佳的解决方法,假如某个表中有200万条记录,第一页取前20条,第二页取21-40条记录,第三页取41-60条记录,依此类推

  SELECT * FROM 表名 LIMIT 0,20;//第一页
  SELECT * FROM 表名 LIMIT 20,20;//第二页
  SELECT * FROM 表名 LIMIT 40,20;//第三页

1.3 分页代码实现步骤

  第一步:确定每页显示的数据数量

  第二步:确定分页显示所需的总页数

  第三步:编写SQL查询语句,实现数据查询

  第四步:在JSP页面中进行分页显示设置

1.3.1 数据库准备

CREATE DATABASE information
DROP TABLE student
CREATE TABLE `student`(
`sid` INT PRIMARY KEY COMMENT '学号',
`sname` VARCHAR(10) NOT NULL COMMENT '姓名',
`password` VARCHAR(10) NOT NULL COMMENT '密码',
`sex` VARCHAR(5) NOT NULL COMMENT '性别',
`phone` VARCHAR(15) NOT NULL COMMENT '手机号',
`qq` VARCHAR(15) NOT NULL COMMENT 'QQ号',
`sclass` VARCHAR(5) NOT NULL COMMENT '班级',
`grade` VARCHAR(5) NOT NULL COMMENT '年纪'
);

INSERT INTO `student` VALUES(20221001,'赵馨','123456','女','15768965625','254562145','1','高一');
INSERT INTO `student` VALUES(20221002,'向翔','123456','男','15796542135','254554845','1','高一');
INSERT INTO `student` VALUES(20221003,'伯姜洲','123456','男','89745215488','254567845','1','高一');
INSERT INTO `student` VALUES(20221004,'千柿鬼鲛','123456','女','12458762145','254561478','1','高一');
INSERT INTO `student` VALUES(20221005,'弥彦','123456','女','15768961245','254784145','2','高一');
INSERT INTO `student` VALUES(20221006,'蝎','123456','女','1458954621','2545628745','2','高一');
INSERT INTO `student` VALUES(20221007,'飞段','123456','男','7895425484','2545541245','2','高一');
INSERT INTO `student` VALUES(20221008,'大蛇丸','123456','男','12456784512','258542145','2','高一');
INSERT INTO `student` VALUES(20221009,'小南','123456','女','32145784512','254567895','1','高二');
INSERT INTO `student` VALUES(20221010,'迪达拉','123456','女','36547895412','254478145','1','高二');
INSERT INTO `student` VALUES(20221011,'角都','123456','男','15745125625','254578125','1','高二');
INSERT INTO `student` VALUES(20221012,'绝','123456','男','15768451225','254565127','1','高二');
INSERT INTO `student` VALUES(20221013,'长门','123456','男','15766532625','254514745','2','高二');
INSERT INTO `student` VALUES(20221014,'宇智波带士','123456','男','17845965625','251542145','2','高二');
INSERT INTO `student` VALUES(20221015,'油女志乃','123456','女','15184565625','254985145','2','高二');
INSERT INTO `student` VALUES(20221016,'春野樱','123456','女','15745128725','254566585','2','高二');
INSERT INTO `student` VALUES(20221017,'佐助','123456','男','15768478955','254562623','1','高三');
INSERT INTO `student` VALUES(20221018,'漩涡鸣人','123456','男','15774512625','251242145','1','高三');
INSERT INTO `student` VALUES(20221019,'赤丸','123456','男','15768512455','254562587','1','高三');
INSERT INTO `student` VALUES(20221020,'木叶丸','123456','男','15768784525','254515445','1','高三');
INSERT INTO `student` VALUES(20221021,'张三','123456','男','15768966521','254562964','2','高三');
INSERT INTO `student` VALUES(20221022,'李四','123456','男','15768784425','254562328','2','高三');
INSERT INTO `student` VALUES(20221023,'王五','123456','男','15761487445','254562582','2','高三');
INSERT INTO `student` VALUES(20221024,'赵六','123456','男','15768541425','254567815','2','高三');
INSERT INTO `student` VALUES(20221025,'赵','123456','女','15768965625','254562145','1','高一');
INSERT INTO `student` VALUES(20221026,'向','123456','男','15796542135','254554845','1','高一');
INSERT INTO `student` VALUES(20221027,'伯姜','123456','男','89745215488','254567845','1','高一');
INSERT INTO `student` VALUES(20221028,'千柿鬼','123456','女','12458762145','254561478','1','高一');
INSERT INTO `student` VALUES(20221029,'弥','123456','女','15768961245','254784145','2','高一');
INSERT INTO `student` VALUES(20221030,'蝎1','123456','女','1458954621','2545628745','2','高一');
INSERT INTO `student` VALUES(20221031,'飞','123456','男','7895425484','2545541245','2','高一');
INSERT INTO `student` VALUES(20221032,'大蛇','123456','男','12456784512','258542145','2','高一');
INSERT INTO `student` VALUES(20221033,'小','123456','女','32145784512','254567895','1','高二');
INSERT INTO `student` VALUES(20221034,'迪达','123456','女','36547895412','254478145','1','高二');
INSERT INTO `student` VALUES(20221035,'角','123456','男','15745125625','254578125','1','高二');
INSERT INTO `student` VALUES(20221036,'绝0','123456','男','15768451225','254565127','1','高二');
INSERT INTO `student` VALUES(20221037,'长','123456','男','15766532625','254514745','2','高二');
INSERT INTO `student` VALUES(20221038,'tgedg','123456','男','17845965625','251542145','2','高二');
INSERT INTO `student` VALUES(20221039,'油女志','123456','女','15184565625','254985145','2','高二');
INSERT INTO `student` VALUES(20221040,'春野','123456','女','15745128725','254566585','2','高二');
INSERT INTO `student` VALUES(20221041,'佐','123456','男','15768478955','254562623','1','高三');
INSERT INTO `student` VALUES(20221042,'漩涡鸣','123456','男','15774512625','251242145','1','高三');
INSERT INTO `student` VALUES(20221043,'赤','123456','男','15768512455','254562587','1','高三');
INSERT INTO `student` VALUES(20221044,'木叶','123456','男','15768784525','254515445','1','高三');
INSERT INTO `student` VALUES(20221045,'张','123456','男','15768966521','254562964','2','高三');
INSERT INTO `student` VALUES(20221046,'李','123456','男','15768784425','254562328','2','高三');
INSERT INTO `student` VALUES(20221047,'王','123456','男','15761487445','254562582','2','高三');
INSERT INTO `student` VALUES(20221048,'赵','123456','男','15768541425','254567815','2','高三');

1.3.2 数据库配置文件

driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/information
username=root
password=huanghuang
initialSize=10
maxActive=80
maxIdle=5
maxWait=3000

1.3.3 创建实体类

分页实体类:Page类

  分页数据根据所需的实体类。类中包含页码、页大小(每页显示多少条数据)、总条数、总页数、起始行

package cn.bdqn.entity;
public class Page {
    private Integer pageIndex;//页码
    private Integer pageSize;//页大小  显示多少行数据
    private Integer totalCounts;//数据的总行数
    private Integer totalPages;//总页数
    private Integer startRows;//起始行

    public Page(Integer pageIndex) {
        this(pageIndex, 8);
    }

    public Page(Integer pageIndex, Integer pageSize) {
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
        this.setStartRows((pageIndex - 1) * pageSize);
    }


    public Integer getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(Integer pageIndex) {
        this.pageIndex = pageIndex;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getTotalCounts() {
        return totalCounts;
    }

    public void setTotalCounts(Integer totalCounts) {
        this.totalCounts = totalCounts;

        this.setTotalPages(totalCounts % pageSize == 0 ? totalCounts / pageSize : totalCounts / pageSize + 1);
    }

    public Integer getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(Integer totalPages) {
        this.totalPages = totalPages;
    }

    public Integer getStartRows() {
        return startRows;
    }

    public void setStartRows(Integer startRows) {
        this.startRows = startRows;
    }

    @Override
    public String toString() {
        return "Page{" +
                "pageIndex=" + pageIndex +
                ", pageSize=" + pageSize +
                ", totalCounts=" + totalCounts +
                ", totalPages=" + totalPages +
                ", startRows=" + startRows +
                '}';
    }
}

学生实体类:Student类

package cn.bdqn.entity;

public class Student {
    private int sid;
    private String sname;
    private String password;
    private String sex;
    private String phone;
    private String qq;
    private String sclass="";
    private String grade="";


    public Student() {
    }

    public Student(int sid, String sname, String password, String sex, String phone, String qq, String sclass, String grade) {
        this.sid = sid;
        this.sname = sname;
        this.password = password;
        this.sex = sex;
        this.phone = phone;
        this.qq = qq;
        this.sclass = sclass;
        this.grade = grade;
    }

    public int getSid() {
        return sid;
    }

    public void setSid(int sid) {
        this.sid = sid;
    }

    public String getSname() {
        return sname;
    }

    public void setSname(String sname) {
        this.sname = sname;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getQq() {
        return qq;
    }

    public void setQq(String qq) {
        this.qq = qq;
    }

    public String getSclass() {
        return sclass;
    }

    public void setSclass(String sclass) {
        this.sclass = sclass;
    }

    public String getGrade() {
        return grade;
    }

    public void setGrade(String grade) {
        this.grade = grade;
    }

    @Override
    public String toString() {
        return "Student{" +
                "sid=" + sid +
                ", sname='" + sname + '\'' +
                ", password='" + password + '\'' +
                ", sex='" + sex + '\'' +
                ", phone='" + phone + '\'' +
                ", qq='" + qq + '\'' +
                ", sclass='" + sclass + '\'' +
                ", grade='" + grade + '\'' +
                '}';
    }
}

1.3.4 创建StudentDao接口

package cn.bdqn.dao;

//import cn.bdqn.entity.PageBean;
import cn.bdqn.entity.Page;
import cn.bdqn.entity.Student;

import java.util.List;

public interface StudentDao {
    //对Student表进行增删改查。
    int insert(Student student);
    int update(Student student);
    int delete(int sid);
    Student selectOne(int sid);
    //获取学号和密码相匹配的学生
    Student selectOne(int sid, String password);
    List<Student> selectAll();

    void deleteByIds(String[] ids);
    //条件查询
    List<Student> allInfo2(Student student);


    //条件查询的结果上,统计总记录,把分页条件作为参数
    Long totalCounts();

    //升级:分页功能
//    List<Student> allInfo(PageBean pageBean);

    public List<Student> selectAll(Page page);

    public long selectCount();

    public List<Student> searchByStuName(String stuName);
}

1.3.5 StudentDaoImpl实现类

package cn.bdqn.dao.impl;

import cn.bdqn.dao.StudentDao;
//import cn.bdqn.entity.PageBean;
import cn.bdqn.entity.Page;
import cn.bdqn.entity.Student;
import cn.bdqn.utils.DBUtils;
import org.apache.commons.dbutils.DbUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.apache.commons.dbutils.handlers.ScalarHandler;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class StudentDaoImpl implements StudentDao {
    private QueryRunner queryRunner=new QueryRunner(DBUtils.getDataSource());
    //对Student表进行增删改查
    @Override
    public int insert(Student student) {
        String sql="insert into `student` values(?,?,?,?,?,?,?,?);";
        Object[] args={student.getSid(),student.getSname(),student.getPassword(),student.getSex(),student.getPhone(),student.getQq(),student.getSclass(),student.getGrade()};
        try {
            return queryRunner.update(sql,args);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public int update(Student student) {
        String sql="update `student` set sname=?,password=?,sex=?,phone=?,qq=?,sclass=?,grade=? where sid=?;";
        Object[] args={student.getSname(),student.getPassword(),student.getSex(),student.getPhone(),student.getQq(),student.getSclass(),student.getGrade(),student.getSid()};

        try {
            return queryRunner.update(sql,args);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public int delete(int sid) {
        String sql="delete from `student` where sid=?";

        try {
            return queryRunner.update(sql,sid);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public Student selectOne(int sid) {
        String sql="select * from `student` where sid=?;";
        try {
            return queryRunner.query(sql,new BeanHandler<Student>(Student.class),sid);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    //获取学号和密码相匹配的学生
    @Override
    public Student selectOne(int sid, String password) {
        String sql="select * from `student` where sid=? and password=?;";
        Object[] args={sid,password};
        try {
            return queryRunner.query(sql,new BeanHandler<Student>(Student.class),args);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public List<Student> selectAll() {
        String sql="select * from `student`;";

        try {
            return queryRunner.query(sql,new BeanListHandler<Student>(Student.class));
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void deleteByIds(String[] ids) {
        for (String id : ids) {

           delete(Integer.parseInt(id));
        }

    }
//条件查询sql语句
    @Override
    public List<Student> allInfo2(Student student) {
        String sql="select * from `student` where 1=1 ";
        if(!(student.getSclass()==null || student.getSclass().equals(""))){
            sql+=" and sclass like '%"+student.getSclass()+"%'";
        }
        if(!(student.getGrade()==null || student.getGrade().equals(""))){
            sql+=" and grade like '%"+student.getGrade()+"%'";
        }
//        sql+=" limit ?,?";
        System.out.println("sql"+sql);
        try {
            return queryRunner.query(sql,new BeanListHandler<Student>(Student.class));
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public List<Student> selectAll(Page page) {
        try {
            List<Student> emps = queryRunner.query(DBUtils.getDataSource().getConnection(),"select * from student limit ?,?",new BeanListHandler<Student>(Student.class),page.getStartRows(),page.getPageSize());
            return emps;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public long selectCount() {
        try {
            return (long)queryRunner.query(DBUtils.getDataSource().getConnection(),"select count(*) from student;",new ScalarHandler<>());
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return 0;
    }

    @Override
    public Long totalCounts() {
        String sql="select count(*) from student";//返回的统计结果  记录数


        try {
            return queryRunner.query(sql,new ScalarHandler<Long>());
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    //根据姓名模糊查询
    @Override
    public List<Student> searchByStuName(String stuName){//模糊查询
        String sql="select * from `student` where sname like ?;";
        try {
            return queryRunner.query(sql,new BeanListHandler<Student>(Student.class),stuName);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}

1.3.6 创建StudentService接口

package cn.bdqn.service;

//import cn.bdqn.entity.PageBean;
import cn.bdqn.entity.Page;
import cn.bdqn.entity.Student;
import java.util.List;

public interface StudentService {
    //对Student表进行增删改查。
    int insert(Student student);
    int update(Student student);
    int delete(int sid);
    Student selectOne(int sid);
    //获取学号和密码相匹配的学生
    Student selectOne(int sid, String password);
    List<Student> selectAll();
    //选择删除方法
    void deleteByIds(String[] ids);
    //条件查询
    List<Student> allInfo2(Student student);
    //分页
//    List<Student> allInfo(PageBean pageBean);
    public List<Student> selectAll(Page page);
    public long selectCount();
    //姓名模糊查询
    public List<Student> searchByStuName(String stuName);
}

1.3.7 StudentServiceImpl实现类

package cn.bdqn.service.impl;

import cn.bdqn.dao.StudentDao;
import cn.bdqn.dao.impl.StudentDaoImpl;
//import cn.bdqn.entity.PageBean;
import cn.bdqn.entity.Page;
import cn.bdqn.entity.Student;
import cn.bdqn.service.StudentService;

import java.util.List;

public class StudentServiceImpl implements StudentService {
    StudentDao studentDao=new StudentDaoImpl();
    @Override
    public int insert(Student student) {
        return studentDao.insert(student);
    }

    @Override
    public int update(Student student) {
        return studentDao.update(student);
    }

    @Override
    public int delete(int sid) {
        return studentDao.delete(sid);
    }

    @Override
    public Student selectOne(int sid) {
        return studentDao.selectOne(sid);
    }

    //获取学号和密码相匹配的学生
    @Override
    public Student selectOne(int sid, String password) {
        return studentDao.selectOne(sid,password);
    }

    @Override
    public List<Student> selectAll() {
        return studentDao.selectAll();
    }

    @Override
    public void deleteByIds(String[] ids) {
        studentDao.deleteByIds(ids);
    }

    @Override
    public List<Student> allInfo2(Student student) {
        return studentDao.allInfo2(student);
    }

    @Override
    public List<Student> selectAll(Page page) {
        return studentDao.selectAll(page);
    }

    @Override
    public long selectCount() {
        return studentDao.selectCount();
    }

    @Override
    public List<Student> searchByStuName(String stuName) {
        return studentDao.searchByStuName(stuName);
    }
}

1.3.8 studentShow0.jsp

<%@ page import="java.util.List" %>
<%@ page import="cn.bdqn.entity.Page" %>
<%@ page import="cn.bdqn.service.StudentService" %>
<%@ page import="cn.bdqn.service.impl.StudentServiceImpl" %>
<%@ page import="cn.bdqn.entity.Student" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="../js/jQuery-3.6.1.js"></script>
    <script src="../img/student/iconfont.js"></script>
    <link rel="stylesheet" href="./img/student/demo.css">
<%--    <link href="./css/pubCss.css" rel="stylesheet">--%>
<%--    <link href="./css/show.css" rel="stylesheet">--%>
    <style>
        #insertStudent
        {
            display: block;
            width: 150px;
            height: 50px;
            background-color: pink;
            text-align: center;
            line-height: 50px;
            text-decoration: none;
            color: white;
        }

        .inputBtn{
            font-size: 18px;
            padding: 5px 15px;
            background: rgba(255,255,255,50%);

            color: darkblue;
            border-color: #3967FF;
            border-radius: 10px;
            margin-top: 20px;
            margin-bottom: 20px;
        }
        .inputBtnAdd{
            font-size: 18px;
            padding: 5px 15px;
            margin-top: 30px;
            margin-bottom: -60px;
            background: rgba(255,255,255,50%);
            color: blue;
            float: left;
            display: inline;
        }
        form{
            display: inline;
        }
        td{width:200px;height:45px;line-height:45px;text-align:center;font-size:18px}
        table tr:nth-child(odd){background:#1A417C; }
        table tr:nth-child(even){background:cornflowerblue;}
        /*.divTable{*/
        /*    background: #ccc;*/
        /*    !*margin: 10px 20px;*!*/
        /*}*/
        table{
            width: 100%;
            color: white;
        }
        th{height:35px;line-height:35px;text-align:center;background:white; font-size: 20px;color: #1A417C}

        .input0{display:none;}

        .tdPage a{
            border: 1px solid darkblue;
            background: #1A417C;
            /*background-image: url("../img/矩形按钮.png");*/
            /*background-repeat:repeat;*/
            border-radius: 10px;
            padding: 5px 10px;
            width: 200px;
            height: 50px;
            color: white;
        }
        .tdPage a:hover{
            color: yellow;
        }
        .ulSearch li{
            float: left;
            position: relative;
            list-style: none;
        }
        .ulSearch span{
            margin-left: 10px;
        }
        .ulSearch a{
            position: absolute;
            right: 10px;
            top: 5px;
        }
        .icon {
            width: 18px;
            height: 18px;
            vertical-align: -0.15em;
            fill: currentColor;
            overflow: hidden;
        }
       </style>
</head>
<body>
<%
    String pageIndex = request.getParameter("pageIndex");

    if(pageIndex==null){//如果是第一次访问
        pageIndex ="1";
        request.setAttribute("pageIndex",pageIndex);
    }

    Page page1 = new Page(Integer.valueOf(pageIndex));

    //调用Dao,获取所有数据
    StudentService studentService = new StudentServiceImpl();
    long count = studentService.selectCount();
    page1.setTotalCounts((int)count);
    List<Student> students = studentService.selectAll(page1);
    request.setAttribute("students",students);
    request.setAttribute("page1",page1);
%>
<div class="divTable">
    <ul class="ulSearch" style="padding:3px">
        <li>
            <span>【学号查询】</span>
            <form id="stuId" action="ServletSearch">
                <input type="text" name="keyword" style="line-height:26px;border:1px solid #ccc">
                <input type="text" name="method" value="searchByStuId" style="line-height:26px;border:1px solid #ccc;display: none">
                <a href="<c:url context='${pageContext.request.contextPath}'
                 value='/managerSafe/CenterServlet?studentPage=studentShow0.jsp?tag=2?pageIndex=1' />">
                    <svg class="icon" aria-hidden="true">
                        <use xlink:href="#icon-sousuo"></use>
                    </svg>
                </a>
            </form>
        </li>
        <li>
            <span>【姓名查询】</span>
            <form id="stuName" action="ServletSearch">
                <input type="text" name="keyword" style="line-height:26px;border:1px solid #ccc">
<%--                <input type="text" name="method" value="searchByStuName" style="line-height:26px;border:1px solid #ccc;display: none">--%>
                <a href="<c:url context='${pageContext.request.contextPath}'
                 value='/managerSafe/CenterServlet?studentPage=studentShow0.jsp?tag=3?pageIndex=1' />">
                    <svg class="icon" aria-hidden="true">
                        <use xlink:href="#icon-sousuo"></use>
                    </svg>
                </a>
            </form>
        </li>
        <li>
            <span>【年级查询】</span>
            <input id="stuGrade" style="line-height:26px;border:1px solid #ccc">
            <a><svg class="icon" aria-hidden="true">
                <use xlink:href="#icon-sousuo"></use>
            </svg></a>
        </li>
        <li>
            <span>【班级查询】</span>
            <input id="stuClass" style="line-height:26px;border:1px solid #ccc">
            <a><svg class="icon" aria-hidden="true">
                <use xlink:href="#icon-sousuo"></use>
            </svg></a>
        </li>
    </ul>
    <table>
        <tr>
            <th>学号</th>
            <th>姓名</th>
            <th>性别</th>
            <th>手机号</th>
            <th>QQ</th>
            <th>班级</th>
            <th>年级</th>
            <th>操作</th>
        </tr>
        <c:forEach var="student" items="${students}">
            <tr>
                <td>${student.sid}</td>
                <td>${student.sname}</td>
                <td>${student.sex}</td>
                <td>${student.phone}</td>
                <td>${student.qq}</td>
                <td>${student.sclass}</td>
                <td>${student.grade}</td>
                <td>
                    <form action="ServletDel" method="post">
                        <input type="text" name="rid" value="${student.sid}" style="display: none">
                        <input class='inputBtn' type="button" value="删除" onclick='deleteRecord(this)'>
                    </form>
                    <form action="ServletUpdate" method="post">
                        <input type="text" name="rid" value="${student.sid}" style="display: none">
                        <input class='inputBtn' type="submit" value="修改">
                    </form>
                </td>
            </tr>
        </c:forEach>
        <tr>
            <td colspan="8" class="tdPage">

                <c:if test="${page1.pageIndex > 1}">
                    <a href="<c:url context='${pageContext.request.contextPath}' value='/managerSafe/CenterServlet?studentPage=studentShow0.jsp?tag=1?pageIndex=1' />">首页</a>
                    <a href="<c:url context='${pageContext.request.contextPath}' value='/managerSafe/CenterServlet?studentPage=studentShow0.jsp?tag=1?pageIndex=${page1.pageIndex - 1}' />">上一页</a>
                </c:if>
                <c:if test="${page1.pageIndex == 1}">
                    <a style="color: #ccc">首页</a>
                    <a style="color: #ccc">上一页</a>
                </c:if>

                <c:if test="${page1.pageIndex < page1.totalPages}">
                    <a href="<c:url context='${pageContext.request.contextPath}' value='/managerSafe/CenterServlet?studentPage=studentShow0.jsp?pageIndex=${page1.pageIndex + 1}'/>">下一页</a>
                    <a href="<c:url context='${pageContext.request.contextPath}' value='/managerSafe/CenterServlet?studentPage=studentShow0.jsp?pageIndex=${page1.totalPages}'/>">尾页</a>
                </c:if>
                <c:if test="${page1.pageIndex == page1.totalPages}">
                    <a style="color: #ccc">下一页</a>
                    <a style="color: #ccc">尾页</a>
                </c:if>

            </td>
        </tr>
    </table>
</div>

</body>
<script type="text/javascript" src="../js/stuChange.js"></script>
</html>

1.3.9 运行效果图部分截图

在这里插入图片描述

在这里插入图片描述


  码文不易,本篇文章就介绍到这里,如果想要学习更多Java系列知识点击关注博主,博主带你零基础学习Java知识。与此同时,对于日常生活有困扰的朋友,欢迎阅读我的第四栏目:《国学周更—心性养成之路》,学习技术的同时,我们也注重了心性的养成。

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/155589.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Homekit智能家居DIY产品一智能面板开关

触摸开关&#xff0c;即通过触摸方式控制的墙壁开关&#xff0c;其感官场景如同我们的触屏手机&#xff0c;只需手指轻轻一点即可达到控制电器的目的&#xff0c;随着人们生活品质的提高&#xff0c;触摸开关将逐渐将换代传统机械按键开关。 触摸开关控制原理 触摸开关我们把…

【广度优先搜索遍历 BFS】单词接龙

一、题目描述 字典 wordList 中从单词 beginWord 和 endWord 的 转换序列 是一个按下述规格形成的序列 beginWord -> s1 -> s2 -> ... -> sk&#xff1a; - 每一对相邻的单词只差一个字母。 - 对于 1 < i < k 时&#xff0c;每个 si 都在 wordList 中。注意…

全面详解Java垃圾回收器

一&#xff1a;什么是垃圾回收 Java 方法栈、本地方法栈随着方法结束或者线程结束&#xff0c;堆中的对象是用完&#xff0c;都会进行回收内存&#xff0c;所以这些区域的内存分配和回收都具备确定性&#xff0c;不需要额外考虑回收的问题。而堆和方法区存储的对象可能只有在运…

Ad5761r GD32 STM32 驱动设计

MCU采用GD32,GD32基本上和STM32一样,针对ad5761r的时序操作是完全相同的.软、硬件设计已经再产品设计中实际使用。本文章提供参考硬件设计&#xff0c;以及对应的源代码&#xff0c;具体可以作为实际项目的参考设计AD5761R是一款单通道、16位串行输入、电压输出DAC。该器件采用…

网工进阶之路-锐捷NAT网络地址转换实验 ----尚文网络奎哥

实验拓扑&#xff1a;实验需求&#xff1a; 1&#xff1a;方框内设备为内网设备&#xff0c;方框外是外网设备&#xff0c;内网网段为192.168.1.0/24&#xff0c;外网路由器互联网段为100.1.1.0/24&#xff0c;外网PC网段为200.1.1.0/24 2&#xff1a;希望使用各种NAT实现内网…

2023年海外优青项目申报指南及政策解读

海外优青项目申报&#xff0c;一直备受海外优秀青年学者&#xff08;包括博士后研究人员&#xff09;关注。知识人网小编现将国家自然科学基金委员会公布的2023年申报指南全文摘录&#xff0c;并和往年加以对比进行政策解读&#xff0c;以飨读者。自2021年起&#xff0c;国家自…

【面试题】说说你对发布订阅、观察者模式的理解?区别?

大厂面试题分享 面试题库前端面试题库 &#xff08;面试必备&#xff09; 推荐&#xff1a;★★★★★地址&#xff1a;前端面试题库一、观察者模式观察者模式定义了对象间的一种一对多的依赖关系&#xff0c;当一个对象的状态发生改变时&#xff0c;所有依赖于它的对象都将得到…

Elasticsearch-高级搜索(拼音|首字母|简繁|二级搜索)

需求&#xff1a; 中文搜索、英文搜索、中英混搜全拼搜索、首字母搜索、中文全拼、中文首字母混搜简繁搜索二级搜索&#xff08;对第一次搜索结果&#xff0c;再进行搜索&#xff09;一、ES相关插件 IK分词&#xff1a; GitHub - medcl/elasticsearch-analysis-ik: The IK A…

JsonWebToken远程代码执行漏洞(CVE-2022-23529)

漏洞描述 JsonWebToken 是一个用于创建、签名和验证 JSON Web Token开源库。node-jsonwebtoken是node.js 下 JsonWebToken 的实现。 在JsonWebToken < 8.5.1版本中由于jwt.verify()方法未对用户输入的secretOrPublicKey参数进行有效的检查。如果攻击者能够控制secretOrPub…

【docker12】docker复杂安装

docker复杂安装 之前是单机版&#xff0c;自娱自乐还是不错滴&#xff0c;但是如果是生产开发环境中是需要复杂集群安装的 1.安装mysql主从复制 1.1主从复制原理&#xff08;记得补&#xff09; 1.2主从搭建步骤 新建主服务器容器实例3307 命令&#xff1a; docker run -d …

Unity 实现一个特定动画状态切换树

前言 今天在工作中接到一需求,要求人物摆在不同的9个格子上,在哪个格子上,就走哪个格子动画播放逻辑; 打个比方:第一个格子上有台电脑,我将角色放上去,角色就玩电脑,每播完一次动画,就根据概率判断是否需要去喝水,最终实现的效果,就是将角色放上去,并且随机时间进行喝水;第二个…

TiDB 底层存储结构 LSM 树原理介绍

随着数据量的增大&#xff0c;传统关系型数据库越来越不能满足对于海量数据存储的需求。对于分布式关系型数据库&#xff0c;我们了解其底层存储结构是非常重要的。本文将介绍下分布式关系型数据库 TiDB 所采用的底层存储结构 LSM 树的原理。 1 LSM 树介绍 LSM 树&#xff08…

测试开发基础 mvn test | 利用 Maven Surefire Plugin 做测试用例基础执行管理

一、需求在测试工作场景中&#xff0c;经常会遇到下面的问题&#xff1a;1、执行自动化测试用例的时候&#xff0c;只想指定某个测试类&#xff0c;或者某个方法&#xff0c;又或者某一类用例等&#xff0c;怎么办&#xff1f;2、想要和 Jenkins 一起进行持续集成&#xff0c;可…

C语言_文件操作(下)

目录 8. 文件的随机读写 8.1 fseek 8.2 ftell 8.3 rewind ​9. 文件结束判定 10. perror 8. 文件的随机读写 假设文件中存放的是abcdef&#xff0c;如下图&#xff0c;通常在读文件时&#xff0c;是先读取首元素地址&#xff0c;也就是文件指针指向a&#xff0c;每读一…

【Linux进程信号】

Linux进程信号技术应用角度的信号信号的发送与记录信号处理常见方式产生信号通过终端按键产生信号通过系统函数向进程发信号由软件条件产生信号由硬件异常产生信号阻塞信号信号其他相关常见概念在内核中的表示sigset_t信号集操作函数sigprocmasksigpending捕捉信号内核空间与用…

three.js 之 入门篇 5之几何体的认知( 顶点创建矩阵、炫酷三角形科技物体、基础网格材质 material )

目录three.js 之 入门篇 5之几何体的认知01BufferGeometry设置顶点创建矩阵02 生产炫酷三角形科技物体03 常见的网格几何体 geometry04 基础网格材质 material04-1 初识别材质与纹理04-2 初识别材质与纹理 &#xff08; 平移、旋转 &#xff09;04-3 纹理显示设置&#xff08; …

C语言——指针面试题详解

&#x1f412;个人主页&#xff1a;平凡的小苏&#x1f4da;学习格言&#xff1a;别人可以拷贝我的模式&#xff0c;但不能拷贝我不断往前的激情目录 1. 指针和数组笔试题解析 一维数组 字符数组 二维数组 2. 指针笔试题 笔试题1&#xff1a; 笔试题2&#xff1a; 笔试题…

ffmpeg 颜色空间转换分析

颜色空间转换有很多相关标准&#xff1a; https://docs.opencv.org/3.4.0/de/d25/imgproc_color_conversions.html https://www.itu.int/rec/R-REC-BT.601-4-199407-S/en ffmpeg命令行颜色空间转换是通过调用vf_scale中的swscale来进行转码。 我们通过gdb来调试ffmpeg. 首先编译…

《Getting Started with NLP》chap11:Named-entity recognition

《Getting Started with NLP》chap11&#xff1a;Named-entity recognition 最近需要做一些NER相关的任务&#xff0c;来学习一下这本书的第十一章 文章目录《Getting Started with NLP》chap11&#xff1a;Named-entity recognition11.1 Named entity recognition: Definition…

jar转成dex文件

jar转成dex文件 dx 可以利用android studio中的dx工具。 可以看到android的tool安装位置: 在此路径下的如下目录有dx.bat,这个正是我们需要使用的工具。 D:\sdk\build-tools\30.0.3将dx.bat添加到环境变量 基本指令 > dx --dex --output 输出路径 待转化的jar包C