学习内容
所花时间:2小时
代码量:如下:
博客量:本学期截至目前39篇
了解到的知识点:分页查询
在今天我学会了分页查询的操作:
以下是部分代码:
index.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | <%@ taglib prefix= "c" uri= "http://java.sun.com/jsp/jstl/core" %> <%@ page import = "java.util.ArrayList" %> <%@ page import = "bean.policy" %><%-- Created by IntelliJ IDEA. User: Lenovo Date: 2023 / 4 / 10 Time: 15 : 19 To change this template use File | Settings | File Templates. --%> <%@ page contentType= "text/html;charset=UTF-8" language= "java" %> <html> <head> <title>Title</title> </head> <body> <center> <img src= "LOGO.png" > </center> <% request.setCharacterEncoding( "UTF-8" ); response.setCharacterEncoding( "UTF-8" ); Object message=request.getAttribute( "message" ); if (message!= null ) { %> <script language= "JavaScript" >alert( "<%=message%>" )</script> <% } ArrayList<policy> policies= (ArrayList<policy>) request.getAttribute( "policies" ); if (policies== null ){ %> <form action= "Servlet?method=suoyou" method= "post" > <input type= "submit" value= "查询" > </form> <% } else if (policies!= null ){ %> <center> <form action= "Servlet?method=chadata" method= "post" > 政策名称:<input type= "text" name= "name" placeholder= "请输入政策名称" style= "border: none" > 发文字号:<input type= "text" name= "document" placeholder= "请输入发文字号" style= "border: none" > 发文机构:<input type= "text" name= "organ" placeholder= "请输入发文机构" style= "border: none" > 全文检索:<input type= "text" name= "data" style= "border: none" > <input type= "submit" value= "搜索" > </form> <br> <br> <table border= "1" cellspacing= "0" > <th width= "10%" >id</th><th width= "20%" >政策名称</th><th width= "20%" >发文机构</th><th width= "20%" >颁布日期</th><th width= "20%" >政策分类</th><th width= "10%" >操作</th> <c:forEach items= "${policies}" var= "item" > <tr> <td>${item.id}</td> <td>${item.name}</td> <td>${item.organ}</td> <td>${item.pubdata}</td> <td>${item.type}</td> <td><a href= "Servlet?method=chakan&id=${item.id}" style= "text-decoration: none" >查看</a> </td> </tr> </c:forEach> </table> <br> 共${sum}条记录,当前第${cpage}/${tpage}页 <% String dd= request.getAttribute( "dd" ).toString(); if (Integer.parseInt(request.getAttribute( "sum" ).toString())< 10 ){ } else if (dd.equals( "d" )){%> <a href= "Servlet?method=suoyou&cp=1" >首页</a> <a href= "Servlet?method=suoyou&cp=${cpage-1<=0?1:cpage-1}" >上一页</a> <a href= "Servlet?method=suoyou&cp=${cpage+1>=tpage?tpage:cpage+1}" >下一页</a> <a href= "Servlet?method=suoyou&cp=${tpage}" >尾页</a> <% } else if (dd.equals( "dd" )){%> <a href= "Servlet?method=chadata&cp=1&name=<%=request.getAttribute(" name ")%>&document=<%=request.getAttribute(" document ")%>&organ=<%=request.getAttribute(" organ ")%>" >首页</a> <a href= "Servlet?method=chadata&cp=${cpage-1<=0?1:cpage-1}&name=<%=request.getAttribute(" name ")%>&document=<%=request.getAttribute(" document ")%>&organ=<%=request.getAttribute(" organ ")%>" >上一页</a> <a href= "Servlet?method=chadata&cp=${cpage+1>=tpage?tpage:cpage+1}&name=<%=request.getAttribute(" name ")%>&document=<%=request.getAttribute(" document ")%>&organ=<%=request.getAttribute(" organ ")%>" >下一页</a> <a href= "Servlet?method=chadata&cp=${tpage}&name=<%=request.getAttribute(" name ")%>&document=<%=request.getAttribute(" document ")%>&organ=<%=request.getAttribute(" organ ")%>" >尾页</a> <% } %> </center> <% } %> </body> </html> |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)