<% @ Page Language = "Java" Import = "Java. util. * "pageencoding =" UTF-8 "%> <% @ page import =" cn.com. gnnt. test. pager "%> <% int pagesize = 10; int piecesize = 5; string pagename =" pager. JSP "; // the current page number string S = request. getparameter ("currentpage"); int currentpage = 0; If (s! = NULL) {currentpage = integer. parseint (s);} // list of simulated data <string> List = (list <string>) session. getattribute ("list"); If (list = NULL | list. size () = 0) {list = new arraylist <string> (); random r = new random (); For (INT I = 0; I <100; I ++) {list. add ("Hello, I'm" + (char) ('A' + R. nextint (26) + ". "+ I);} session. setattribute ("list", list);} // simulate data pager = new pager (list. size (), pagesize, piecesize); pager. s Etcurrentpage (currentpage); %> <! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en"> <HTML>
Other paging methods:
An Implementation of Data paging display with JSP (http://www.ibm.com/developerworks/cn/java/l-jspdisp/index.html)