Pager-taglib Paging

Source: Internet
Author: User

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.

 

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.