Summary of pagination---

Source: Internet
Author: User

Pagination Summary:

1. The simple version of the page:

Implementation results such as: Home-prev-Next-last

Be able to follow the corresponding link, the implementation jumps to the corresponding page.

Analysis and Grooming:

A. As long as you know the current page (PAGECODE--PC) and the total number of pages (TOTALPAGE--TP);

B. So, the homepage is: <a href= "Customerservlet?method=findall&pc=1" > Home </a>

Prev: <a href= "Customerservlet?method=findall&pc=${pc-1}" > Prev </a>

Next: <a href= "CUSTOMERSERVLET?METHOD=FINDALL&PC=${PC + 1}" > Next </a>

Last: <a href= "CUSTOMERSERVLET?METHOD=FINDALL&PC=${TP}" > Last </a>

2. Page-Perfect version:

Implementation effects such as: Home-prev-1-2-3-4-5-.....-10-Next page-end

Be able to jump to the corresponding page according to the page number.

Analysis and Grooming:

A. Requirements: Display up to 10 page numbers;

If the current page number is more than 6/10 of the 10 page numbers shown, move to the left. For example: The current page number is 6,

Then when the user presses the next page should move 6 to the left one, before the first "1" is to be replaced by the "2" behind it.

The result is: 2-3-4-5-6-"7"-8-9-10-11.

B. How to determine the number of the first and the number at the end? When should the number be moved and when will it remain the same?

Sets the page number from the begin variable to the end of the end variable. The PC is the current page number, PS is the maximum number of data displayed per page (set to "10" size); TP is the total number of pages; TR is the sum of the data.

* First, determine whether the total number of pages (TP) is greater than "10". If it is greater than 10, then BEGIN = 1, end = 10;

* Then, judge begin = Pc-5 < 1? If begin is less than 1 then the current page is between 1-5, so the page number does not need to be moved. begin = 1,end = 10;

* Finally, Judge end = PC + 4 > TP? If end is greater than TP then the current page is in the penultimate four page, so the page number still does not need to be moved. begin = tp-9, end = TP;

Code:

<a href= "<c:url value="/customerservlet?method=findall&pc=1 "/>" > Home </a> <c:ifTest= "${pb.pc > 1}" > <a href= "<c:url value="/customerservlet?method=findall&pc=${pb.pc-1} "/>" &G t; prev </a> </c:if> <c:choose> <c:when test= "${pb.tp<=10}" > <c:set var= "Begin" value= "1"/> <c:set var= "End" value= "${pb.tp}"/> </c:when> <c:otherwise> <c:set va            R= "Begin" Value= "${pb.pc-5}" ></c:set> <c:set var= "End" value= "${pb.pc+4}" ></c:set> <c:ifTest= "${begin<=1}" > <c:set var= "Begin" value= "1" ></c:set> <c:set var= "E nd "value=" ></c:set> </c:if> <c:ifTest= "${END&GT;=PB.TP}" > <c:set var= "Begin" Value= "${pb.tp-9}" > </c:set> < C:set var= "End" value= "${PB.TP}" ></c:set> </c:if> </c:otherwise> </c:choose> <c:foreach begin= "${begin}" end= "${end}" var= "I" > &L    T;a href= "<c:url value=" Customerservlet?method=findall&pc=${i} "/>" >${i}</a> </c:forEach> <c:ifTest= "${pb.pc < PB.TP}" > <a href= "<c:url value="/customerservlet?method=findall&pc=${pb.pc+1} "/&gt ;" > Next </a> </c:if> <a href= "<c:url value="/customerservlet?method=findall&pc=${pb.tp} "/>" > Last </a>

3. Final page pagination:

(not yet written)

    

Summary of pagination---

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.