Here I will briefly introduce how to use the pager tag library to implement the paging function:
1: On the application server, add the following content to the <web-app>... </Web-app> tag in the Web-INF/Web. xml file of the project:
<Taglib>
<Taglib-Uri>
Http://jsptags.com/tags/navigation/pager // can be changed
</Taglib-Uri>
<Taglib-location>
/WEB-INF/JSP/pager-taglib.tld // specifies where the pager-taglib.tld is stored
</Taglib-location>
</Taglib>
2: To begin. Pager-taglib.tld can go to/webinf/JSP/package.
3: Add: <% @ taglib uri = "http://jsptags.com/tags/navigation/pager" prefix = "PG" %>
4:
<% Totalitems = List. Size (); // list received
String style = "simple"
Sing position = "both"; // top bottom
Int maxpageitems = 1; // number of data displayed on each page
Int maxindexpages = 4; // display the number of redirected pages
String Index = "center ";
%>
<PG: Pager
Items = "<% = totalitems %>"
Index = "<% = index %>"
Maxpageitems = "<% = maxpageitems %>"
Maxindexpages = "<% = maxindexpages %>"
Export = "offset, currentpagenumber = pagenumber"
Scope = "request">
<PG: Param name = "style"/>
<PG: Param name = "position"/>
<PG: Param name = "Index"/>
<PG: Param name = "maxpageitems"/>
<PG: Param name = "maxindexpages"/>
<Input type = "hidden" name = "pager. offset" value = "<% = offset %>">
<% -- Warn if offset is not a multiple of maxpageitems -- %>
<% IF (offset. intvalue () % maxpageitems! = 0 &&
("Alltheweb". Equals (style) | "Lycos". Equals (style )))
{
%>
<P> warning: the current page offset is not a multiple of Max. Page items.
<Br> Please
<PG: First> <a href = "<% = pageurl %>"> return to the first page </a> </PG: First>
If any displayed range numbers appear incorrect. </P>
<% }%>
// Display the jump JSP;
<% IF ("TOP". Equals (position) | "both". Equals (position) {%>
<PG: index> <JSP: Include page = "paging-links.jsp" Flush = "true"/> </PG: index>
<% }%>
<% For (INT I = 0; I <size; I ++) {%>
<PG: item>
<TD> <% = list. Get (I) %> </TD> // simple display of data;
</PG: item>
<%
}
%>
</PG: pager>
5. The paging-links.jsp is as follows: or refer to the demo copy in jsptags to copy the display format you need
<% @ Page session = "false" %>
<% @ Taglib uri = "http://jsptags.com/tags/navigation/pager" prefix = "PG" %>
<Table width = 100% cellpadding = 2 cellspacing = 0 border = 0 bgcolor = e3e9f8>
<Tr> <TD> <font face = Arial size = 2> & nbsp; <B> matches </B> </font>
</TD> <TD align = right nowrap width = 1%> <font face = Arial size =-1>
<PG: Index export = "Total = itemcount">
<PG: Page export = "first, last">
<% = First %>-<% = last %> of <% = Total %>
</PG: Page>
<PG: first export = "url" Unless = "current">
& Nbsp; <B> <a href = "<% = URL %>"> first page </a> </B> & nbsp; |
</PG: First>
<PG: Prev export = "url, first, last">
<% Int previtems = (last. intvalue ()-First. intvalue () + 1; %>
<B> <a href = "<% = URL %>"> previous <% = previtems %> </a> </B>
</PG: Prev>
<PG: Next export = "url, first, last">
<% Int nextitems = (last. intvalue ()-First. intvalue () + 1; %>
| & Nbsp; <B> <a href = "<% = URL %>"> next <% = nextitems %> </a> </B>
</PG: Next>
& Nbsp; </font> </TD> </tr>
</Table>
</PG: index>