Pager.java
Paket Pers.kangxu.datautils.Common; import java.io.serializable; impor java.util.list;/** * * <b> Pagination General Class </b> * * @author kangxu * @param <t> */kelas publik Pager <T> menerapkan serializable {/@param <t> * */Public Class Pager <T> menerapkan Serializable {/@param <T> * 4542617637761955078L; / *** halaman arus saat ini*/ private int currentPage = 1; / *** halaman per halaman ukuran*/ private int pageSize = 10; / *** Jumlah halaman pagetotal*/ private int pagetotal; / *** Jumlah Potongan RecordTotal*/ Private Int RecordTotal = 0; / *** halaman sebelumnya halaman sebelumnya*/ private int sebelumnyapage; / *** Halaman NextPage Next*/ Private Int NextPage; / *** halaman pertama halaman pertama*/ private int firstPage = 1; / *** Halaman terakhir LastPage*/ private int LastPage; / *** konten konten setiap halaman*/ daftar pribadi <T> konten; // Metode set berikut memerlukan penugasan/ ** * Atur halaman saat ini <br> * * @author kangxu * * @param currentpage */ public void setCurrentPage (int currentPage) {this.currentpage = currentPage; } /*** Atur ukuran setiap halaman, Anda juga tidak perlu menetapkan nilai. Ukuran default adalah 10 item <br> * * @author kangxu * * @param pageSize */ public void setPagesize (int pageSize) {this.pagesize = pageSize; } / ** * Tetapkan jumlah total item, defaultnya adalah 0 <br> * * @author kangxu * * @param recordtotal * / public void setRecordTotal (int recordtotal) {this.recordtotal = recordtotal; OtherAttr (); } / ** * Atur konten halaman <br> * * @author kangxu * * @param konten * / public void setContent (daftar <T> konten) {this.content = konten; } / ** * Atur parameter lain * * @author kangxu * * / public void OtherAttr () {// Jumlah total halaman this.pagetotal = this.recordtotal % this.pagesze> 0? this.recordtotal / this.pagesize + 1: this.recordtotal / this.pagesize; // halaman pertama this.firstpage = 1; // halaman terakhir this.lastpage = this.pagetotal; // halaman sebelumnya jika (this.currentpage> 1) {this.previouspage = this.currentpage - 1; } else {this.previouspage = this.firstpage; } // halaman berikutnya jika (this.currentpage <this.lastpage) {this.nextpage = this.currentPage + 1; } else {this.nextpage = this.lastpage; }} // Lepaskan atribut pribadi intert publik getCurrentPage () {return currentPage; } public int getPageSize () {return pageSize; } public int getPageTotal () {return pagetotal; } public int getRecordTotal () {return recordTotal; } public int getPreviousPage () {return sebelumnyapage; } public int getNextPage () {return nextPage; } public int getFirstPage () {return firstPage; } public int getLastPage () {return lastpage; } Daftar Publik <T> getContent () {return content; } @Override Public String ToString () {return "pager [currentPage =" + currentPage + ", pageSize =" + pageSize + ", pagetotal =" + pagetotal + ", recordtotal =" + recordTotal + ", sebelumnyapage =" + sebelumnyapage + ", nextpage =" + "nextpage =", previouspage = " + sebelumnyapage +", nextpage = " + nextpage =", "sebelumnya", " + sebelumnya +", nextpage = " +" + "," sebelumnya "," + " +", nextpage = " +" + "," sebelumnya ", sebelumnya" + ", nextpage =" + " +", nextpage = " +", nextpage = " +", nextpage = " +", nextpage = " +", nextpage = " LastPage + ", Content =" + Content + "]"; }}Menggunakan pagertester.java
Paket Pers.kangxu.datautils.utils; import java.util.arraylist; impor java.util.list; impor pers.kangxu.datautils.common.pager;/** * tes data paginasi * <b> * * </b> * @author kangxu * pagination * public public {public public {Public {Public {public {Public {public {public public {public {public {public {public {public { Pager <string> pager = new pager <string> (); Daftar <String> konten = ArrayList baru <string> (); content.add ("str1"); content.add ("str2"); content.add ("str3"); content.add ("str4"); content.add ("str5"); content.add ("str6"); content.add ("str7"); content.add ("str8"); content.add ("str9"); content.add ("str10"); pager.setCurrentPage (1); pager.setPagesize (10); pager.setrecordtotal (62); pager.setContent (konten); System.out.println (pager); }}Di atas adalah semua konten artikel ini. Saya berharap konten artikel ini akan membantu untuk belajar atau bekerja semua orang. Saya juga berharap untuk mendukung wulin.com lebih lanjut!