【JAVA技术库】分页模糊查询

先上效果图
这里写图片描述

这里写图片描述

这里写图片描述

数据库脚本:

DROP DATABASE csdpsystem;

CREATE DATABASE csdpsystem
CHARACTER SET 'utf8'
COLLATE 'utf8_general_ci';

USE csdpsystem;

CREATE TABLE csdpsystem.student
(
   studentID            VARCHAR(8) NOT NULL,
   studentName          VARCHAR(12),
   studentPassword      VARCHAR(32),
   sStatus              INT ,
   sIdentity            VARCHAR(6)  DEFAULT '学生',
   sLastTime            DATETIME,
   CONSTRAINT pk_studentID  PRIMARY KEY (studentID),
);

COMMIT ;

一共三个页面:使用技术是JSP+JDBC
page.jsp主页面

<%@ page import="java.sql.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    request.setCharacterEncoding("UTF-8");
%>
<html>
<head>
    <%
        String path = request.getContextPath();
        String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    <meta http-equiv="Content-Type" content="text/html; charset='utf-8'" />
    <base href="<%=basePath%>">
    <title>学生查询</title>
</head>
<body>
<%!//设置连接数据库的参数
    private static final String DBDRIVER = "com.mysql.jdbc.Driver";
    private static final String DBURL = "jdbc:mysql://localhost:3306/csdpsystem";
    private static final String DBUSER = "root";
    private static final String DBPASSWORD = "";
%>

<%
    String url = "/jsp/cdsp_information/manager/page.jsp";
    int currentPage = 1;
    String keyWord = "";//默认的关键字
    int lineSize = 5;//每页显示的数据数
    int allRecorders = 0;//保存总记录数
    String column = "studentID";//定义默认的查询列
    String columnData = "用户用户名:studentID|用户姓名:studentName|用户状态:sStatus";//可操作的查询列

    Connection conn = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
%>

<%
    try{//如果没有输入参数那么就会是null,null无法变为数字
        currentPage = Integer.parseInt(request.getParameter("cp"));
    }catch(Exception e){}
    try{//如果没有输入参数那么就会是null,null无法变为数字
        lineSize = Integer.parseInt(request.getParameter("ls"));
    }catch(Exception e){}
    if(request.getParameter("kw")!=null){//表示有查询的关键字
        System.out.println("取得关键字:"+new String(
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值