Paging is a technology that must be applied in Web development. In javaweb technology, beginners generally use the paging technology of SQL statements, and write paging components on this basis. The page passing parameter control layer (servlet or action) calls the paging component method, it is often very troublesome.
However, in actual development, we generally adopt some third-party paging frameworks to make paging quite simple.(Standing on the shoulders of giants)-- Pager-taglib is one of the options..
Pager-taglib is actually a JSP tag library. It is a set of tags designed to display paging information on JSP. Different combinations of these tags support paging display of multiple styles. A variety of different paging pages will be formed. It is also very easy to customize your own style of paging pages.
Next we willPager-taglibPaging for a preliminary understanding.
1. Configure the environment,Copy the pager-taglib.jar packageLibDirectory.
2. Use the taglib command on the JSP page to introduce the pager-taglib tag Library
Use the taglib command to import the tag library as follows:
// Import the paging tag Library
<% @ Tagliburi = "http://jsptags.com/tags/navigation/pager" prefix = "PG" %>
// Import the jstl tag Library
<% @ Taglibprefix = "C"
Uri = "http://java.sun.com/jsp/jstl/core" %>
In this way, you can use the paging tag in the page, the URI attribute value can be obtained in the taglib. TLD file in the tag-taglib.jarMETA-INF directory
3. Use the pager-taglib tag library for paging
Before processingPager-taglibLabel Structure.
<PG: pager>
<PG: item> </PG: item>
<PG: index>
<PG: First> </PG: First>
<PG: Prev> </PG: Prev>
<PG: pages> </PG: pages>
<PG: Next> </PG: Next>
<PG: Last> </PG: Last>
</PG: index>
</PG: pager>
You can use the preceding labels to complete the paging function.,The following is a brief description of the specific labels..
PG: Pager:This label is used to set the overall paging parameters..
PG: first:Tag on the first page.
PG: PreV:Previous Page tag.
PG: Next:Next page tag.
PG: Last:Last Tab.
PG: pages:This label is used to output page number information cyclically..
Next, let's take a simple example.Pager-taglib (OnlyJSPPage,In the next articleArticleWill be displayed as a whole)
<% @ Page Language = "Java" Import = "Java. util. * "pageencoding =" gb18030 "%> <% string Path = request. getcontextpath (); string basepath = request. getscheme () + ": //" + request. getservername () + ":" + request. getserverport () + path + "/"; %> <% @ include file = "/common/Common. JSP "%> <! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en"> <HTML>
Running Effect
The above content isPager-taglibBasic usage,The following article willPager-taglibDetailed introduction to the use of projects.