Pagination Displays data----front end (pagination of information in a database to a Web page)

Source: Internet
Author: User

In the previous article, we have completed the background processing of the pagination display and now proceed to the front-end processing.

Expected display results:

Because of different items, different database data parts, so we will be paged out part of the page to create a separate JSP pages:

1<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "2pageencoding= "UTF-8"%>3<%@ taglib prefix= "C" uri= "Http://java.sun.com/jsp/jstl/core"%>4<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >567<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">8<title>insert title here</title>9Ten<body> One<div id= "Page_nav" align= "Center" > A<a href= "${page.path}?pageno=1" > Home </a> -<a href= "${page.path}?pageno=${page.pagenumber-1}" > Prev </a> -<c:choose> the<c:when test= "${page.totalpage<=5}" > -<c:set var= "Begin" value= "1" ></c:set> -<c:set var= "End" value= "${page.totalpage}" ></c:set> -</c:when> +<c:when test= "${page.pagenumber<=3}" > -<c:set var= "Begin" value= "1" ></c:set> +<c:set var= "End" value= "5" ></c:set> A</c:when> at                      -<c:otherwise> -<c:set var= "Begin" Value= "${page.pagenumber-2}" ></c:set> -<c:set var= "End" value= "${page.pagenumber+2}" ></c:set> -                      -<c:ifTest= "${end>page.totalpage}" > in<c:set var= "Begin" Value= "${page.pagenumber-4}" ></c:set> -<c:set var= "End" value= "${page.totalpage}" ></c:set> to&LT;/C:if> +</c:otherwise> -</c:choose> the                  *<c:foreach begin= "${begin}" end= "${end}" var= "num" > $<c:iftest= "${page.pagenumber== num}" >Panax Notoginseng<a href= "${page.path}?pageno=${num}" > "${num}" </a> -&LT;/C:if> the<c:iftest= "${page.pagenumber!= num}" > +<a href= "${page.path}?pageno=${num}" >${num}</a> A&LT;/C:if> the</c:forEach> +<a href= "${page.path}?pageno=${page.pagenumber +1}" > Next </a> -<a href= "${page.path}?pageno=${page.totalpage}" > End </a> $Total ${page.totalpage} page, ${page.totalrecord} entry to <input value= "${page.totalpage}" name = "pn" id = "Pn_input"/>page $<input type= "button" value= "OK" id= "btn_id"/> -<script type= "Text/javascript" > -$ ("#btn_id"). Click (function () { thevar value= $ ("#pn_input"). Val (); -Window.location= "${page.path}?pageno=" +value;Wuyi }) the</script> -</div> Wu</body> -

    

The above code to achieve the function of the jump page, automatically display 5 pages, and the current page >=3 and <= the total number of pages in the center display, such as "4":

                              

Finally, the paging page is included in the JSP of the Data query Display page.

                  

1     <!--paging Information--2         <% @include file= "/web-inf/view/paging.jsp"%>

Pagination Displays data----front end (pagination of information in a database to a Web page)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.