This article mainly introduces the JSP uses JSTL to implement the paging instance code, has the need friend may refer to the
Using JSTL to display the code is more neat than using JSP, but also makes the code appear less code as follows: <% @page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" UTF-8 "%> <% @taglib prefix=" c " uri =" Http://java.sun.com/jsp/jstl/core "% > <% @page import= "java.util.List"%> <% @page session= "true"%> <% @page errorpage= "error.jsp"%> <html> <head> <meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "> <title> search </title> <script type=" Text/javascript "> function validate1 () {& nbsp var page = Document.forms[0].page.value; if (page.length <= 0) { alert ("Please enter the number of pages to jump to!") "); } else if (isNaN (page) { alert ("Please enter a valid number of pages!") "); } else { document.forms[0].submit (); } </script> </head> <body>   ; Retrieval time: <c:out value= "${result.costtime}"/> Total records: <c:out value= "${result.total}<br>" escapeXml= " False "/> <c:foreach items=" ${resulT.article} "var=" current "varstatus=" status "> <br> <c:out value=" ${status.count+ ( result.pagenum-1) *20} "/> <br> title: <c:out value=" <a href= ' servletdetail?rid=${ Current.rowid} ' >${current.title}</a> ' escapexml= ' false ' ></c:out> <br> Date: <c:out Value= "${current.date}"/> </c:forEach> <table width= "100%" border= "0" align= "center" cellpadding= "0" cellspacing= "0" bgcolor= "#8C8C8C" > <tr> <td height= "align=" Center "bgcolor=" #FFFFFF "> <c:out value=" ${result.pagenum} page/"/> <c:out value=" Total ${result.totalpage} page "/> <c:out value=" ${result.total} records "/> <c:if test=" ${ RESULT.PAGENUM<2} "> <c:out value=" Home | prev "/> </c:if> <c:if Test= "${result.pagenum>=2}" > <c:out value= "<a href=" servletsearch?page=${1}&keyword=${keyword} ' > Home </a> ' escapexml= ' false '/> <c:out value= ' <a href= ' Servletsearch?page=${result.pagenum-1}&keyword=${keyword} ' > Prev </a> ' escapexml= ' false '/> </c:if> <c:out value= "|" /> <c:if test= "${(result.totalpage-result.pagenum) <1}" > <c:out value= "Next page | Last "/> </c:if> <c:if test=" ${(result.totalpage-result.pagenum) >=1} "> <c:out value= "<a href= ' Servletsearch?page=${result.pagenum+1}&keyword=${keyword} ' > next page </a> "escapexml=" false "/> <c:out value=" <a href= ' Servletsearch?page=${result.totalpage} &keyword=${keyword} ' > Last </a> ' escapexml= ' false '/> </c:if> <form action= "Servletsearch" method= "post" > <input type= "text" name= "page" ><input type= "hidden" Name= "KeyWord" Value=${keyword}>   <input type= "button" value= "Jump to" onclick= "validate1 ()" > </form> </table> </body> </html>