Reputation: 5327
I am implementing pagination, for that i have to iterate from 1 to totalPages
in action i have taken variable totalPages which contains total no of pages( like 10, 20,30 etc)
private int totalPages;
in jsp i want to iterate 1 to totalPages using
Upvotes: 0
Views: 411
Reputation: 13734
I think you should do something like this :
page link should be like
<a href="<s:url action="getpage">
<s:param name="pageno" value="4"/>
</s:url>">Page 4</a>
Upvotes: 1
Reputation: 23587
i am not sure what your exact requirement, but for pagination you have to place your logic in your action class which includes
based on above 2 values you will get how many pages you have total.All you need to show them in your jsp and based on the page number you have to calculate the starting record number and the number of record you will fetch.
for showing pages on JSP you have to decide what format you want to have and need to place some sort of if and else statements.
there is nothing like specific to Struts2 and its a generic logic, all dependents upon how you want to implement.
since i believe you will not fetch all the record in one go and will fetch them per page
Upvotes: 1