STRUTS2 Student Information Management System Chapter ③

Source: Internet
Author: User

1  PackageCom.java1234.util;2 3  Public classPageutil {4     //Pass in four parameters, Tagetutil is the head of the jump link, Totalnum is the total number, CurrentPage is the current page, pagesize is the number of each page can be displayed5      Public StaticString Genpagation (String TargetUrl,intTotalnum,intCurrentPage,intpageSize) {6         //define Totalpage, that is, the total number of pages is Totalpage,? When the remainder is 0, select the previous value, and select the second value when it is not set.7         intTotalpage=totalnum%pagesize==0?totalnum/pagesize:totalnum/pagesize+1;8         //Define a StringBuffer9StringBuffer pagecode=NewStringBuffer (); Ten         //The TargetUrl that comes in is the front part of a jump link, paired up? Page=1 can jump to the homepage. OnePagecode.append ("<li><a href= '" +targeturl+ "? page=1 ' > Home </a></li>"); A         //if it is the first page, you can no longer jump, class= ' disabled ' -         if(currentpage==1){ -Pagecode.append ("<li class= ' disabled ' ><a href= ' # ' > Prev </a></li>"); the  -         } -         //if it's not the first page, then the page of ' prev ' is currentPage-1 -         Else{ +Pagecode.append ("<li><a href=" "+targeturl+"? page= "+ (currentPage-1) +" > Prev </a></li> ");  -         } +         //This code is not very clear for the time being what it means A          for(inti=currentpage-2;i<=currentpage+2;i++){ at             // -             if(i<1| | I>totalpage) { -                 Continue; -             } -             if(i=currentpage) { -Pagecode.append ("<li class= ' active ' ><a href= ' # ' >" +i+ "</a></li>"); in  -             } to             Else{ +Pagecode.append ("<li><a href=" "+targeturl+"? page= "+i+" > "+i+" </a></li> ");  -             } the  *         } $         //If the current page is the last page, then the next page is gone, that is class= ' disabled 'Panax Notoginseng         if(currentpage==totalpage) { -Pagecode.append ("<li class= ' disabled ' ><a href= ' # ' > Next </a></li>"); the  +         } A         //if it is not the last page, then the next page is the current page currentpage+1 the         Else{ +Pagecode.append ("<li><a href=" "+targeturl+"? Page "+ (currentpage+1) +" > Next </a></li> "); -         } $         //Page=totalpage is a direct jump to the end of the $Pagecode.append ("<li><a href=" "+targeturl+"? page= "+totalpage+" ' > Last </a></li> "); -         returnpagecode.tostring (); -     } the      -}

STRUTS2 Student Information Management System Chapter ③

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.