Loading

分页查询系统-简单的分页查询的系统

简单的分页查询系统:

可以继续看我之后的博客

https://www.cnblogs.com/rsy-bxf150/p/17334557.html

部分代码:

<%@ page import="dao.Bean" %>
<%@ page import="java.util.ArrayList" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>查询</title>
    <link rel="stylesheet" type="text/css" href="css/main0.css"/>
    <link rel="stylesheet" href="css/bootstrap-grid.min.css">
    <link rel="stylesheet" href="css/bootstrap-reboot.min.css">
    <link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<body>
<nav class="navbar navbar-light bg-light justify-content-between">
    <img src="images/LOGO.png" height="50" width="50">
    <h3>科技政策查询系统</h3>
    <div class="form-inline">
        <form action="Query">
            <input class="form-control mr-sm-2" type="text" placeholder="按名称查询" aria-label="政策查询" name="name">
            <button class="btn btn-outline-success my-2 my-sm-0" type="submit">查询</button>
        </form>
    </div>
</nav>
<!-- 内容块 class="page-block"-->
<div class="container-fluid">
    <div class="page-1">
        <table class="table table-striped table-bordered">
            <tr>
                <th><%="政策名称"%>
                </th>
                <th><%="发文机构"%>
                </th>
                <th><%="颁布日期"%>
                </th>
                <th><%="政策分类"%>
                </th>
            </tr>
        </table>
    </div>
</div>
<script src="./js/index.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>
package main;

import dao.Bean;
import datas.DB;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

//线路查询
@WebServlet("/Show")
public class Show extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        resp.setContentType("text/html;charset=UTF-8");

        String sid =  req.getParameter("sid");

        DB db = new DB();
        String result = null;
        try {
            db.rs = db.stmt.executeQuery("SELECT * FROM policy WHERE id =" + "'"+ sid +"'");
            while (db.rs.next()) {
                result = db.rs.getString("text");//内容
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            db.close();
        }

        if (result!=null){
            req.setAttribute("textResult", result);
            req.getRequestDispatcher("/success.jsp").forward(req, resp);
        }else {
            req.getRequestDispatcher("/fail.jsp").forward(req, resp);
        }

    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
    @Override
    public void init() throws ServletException {
    }
    @Override
    public void destroy() {

    }
}

 

posted @ 2023-04-17 21:41  冰稀饭Aurora  阅读(14)  评论(0编辑  收藏  举报