How to perform pagination in jsp

前端 未结 3 429
梦谈多话
梦谈多话 2021-01-22 01:39

i need pagination concept to display 15 records. this is my jsp file.

<%
ArrayList al = new ArrayList();
%>
<%!String s;
int i;%>
<         


        
相关标签:
3条回答
  • 2021-01-22 02:28

    You can you the Display tag library. It provides paging capability for your JSP page. You just need to pass a list of objects to this taglib and it will add pagination to your page. It also support other functionality such as sorting, grouping, export, etc.

    0 讨论(0)
  • 2021-01-22 02:28

    I am using Display Tag Library and it does everything by fly. Just pass the list into the display:table property and display tag will take care of the rest. You can also use EL with it. It is easy to use and also maintainable.

    0 讨论(0)
  • 2021-01-22 02:31

    The Display Tag library is an open source library which provides pagination functionality while still being easy to use.

    You can set your records in request scope from your servlet class.

    request.setAttribute( "test", new TestList(10, false) );
    

    and Then you can use display tag library to display it with pagination.

    <%@taglib uri="http://displaytag.sf.net" prefix="display" %>
    
    
    <display:table name="test" pagesize="15" >
      <display:column property="id" title="ID" />
      <display:column property="name" />
      <display:column property="email" />
      <display:column property="status" />
      <display:column property="description" title="Comments"/>
    </display:table>
    

    You can find it's basic tutorials here.


    Updated:

    You need not to use <table>, <tr>, <td> tag only <display:table> and <display:column> is enough. You can directly use fields from EmpList inside property tag of <display:column>.

    Follow this tutorial.

    0 讨论(0)
提交回复
热议问题