Use of pager tag library in JSP paging framework

Source: Internet
Author: User

Technology not written for a long timeArticleNow, I am studying. I will summarize my previous things.

For the latest pager version, go to http://jsptags.com/tags/navigation/pager/
Download

Pager uses tags to paging data. It is easy to use and supports custom paging styles.

For example:

The effect is as follows:

Note: The demo uses SSH (struts2 + hibernate + spring). In fact, it can be demonstrated without such complexity. It is only for the purpose of learning and adding CSS styles to the paging effect.

1. First download the pager-taglib.jar and put it in classpath.

2. Write the background method of paging query and return the data to the JSP page.

3. capture the data on the JSP page and display the following data: (required data: the set of current page data returned by the query, and the total number of items returned by the current query)


 

Label description:

PG: Pager
Defines the start tag of a page. In this tag, you can define Pager: Index Pager: Next ...... Equivalent to the html body tag
Format:

Id = "value" // ID is pager by default, which is used to obtain the attributes of pager. Example: request. getparamenter ("pager. offset ");
Url = "url" // The URL used to generate each paging request. The default value is request. getrequesturi (). If the default value is set, the URL parameter will be removed.
Index = "center | forward | half-full" // page display style
Maxpageitems = "int" // number of data entries per page
Maxindexpages = "int" // Number of pages displayed on the page
Scope = "Page | request" // scope of the pager object

>
...

PG: Param
It is equivalent to request. setattribute ("name", "value"). parameters are transmitted by pagination URL.
Format:

Id = "value"
Name = "value"
Value = "value"
/>

PG: Index
Paging index, defined in PG: Pager
Format:

Id = "value"
Export = "expression"
>
...

PG: first
Used in PG: Index to generate a home page Link
Format:

Id = "value"
Unless = "Current | indexed" // display current on the home page: when the current page is the home page, no homepage link is displayed. Indexed: as long as there is a home page in the page, no homepage link is displayed.
Export = "expression"
>
<% = Pageurl %> // URL link
<% = Pagenumber %> // Number of pages
.

PG: Prev
Used in PG: Index to generate a previous page Link
Format:

Id = "value"
Ifnull = "True | false" // whether the previous page Link is always displayed. If the previous page is not displayed, the previous page Link is always displayed!
Export = "expression"
>
<% = Pageurl %>
<% = Pagenumber %>
...

PG: Page
Used in PG: Index to generate the current page number link or export the current page
Format:

Id = "value"
Export = "expression"
>
<% = Pageurl %>
<% = Pagenumber %>
...

PG: pages
Used in PG: Index to generate all page numbers
Format:

Id = "value"
Export = "expression"
>
<% = Pageurl %>
<% = Pagenumber %>
...

PG: Next
Used in PG: Index to generate the next page Link
Format:

Id = "value"
Ifnull = "True | false"
Export = "expression"
>
<% = Pageurl %>
<% = Pagenumber %>
...

PG: Last
Used in PG: Index to generate the link to the last page
Format:

Id = "value"
Unless = "Current | indexed"
Export = "expression"
>
<% = Pageurl %>
<% = Pagenumber %>
...

Related Article

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.