Pagination example in Struts 2.2.1
Posted on: January 21, 2011 at 12:00 AM
In this tutorial you will learn how make a many pages of a large information and displaying them in a limit

Pagination example in Struts 2.2.1

Pagination is a way to divide the data/information into many pages and displaying them one by one in sequence and shorted order. It is required when information the pages become so large to display. Therefore you can divide the information into a limited size and display them.

An example of pagination is given below


<%@ taglib uri="" prefix="display" %>
<%@ taglib uri="" prefix="c" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<title>Pagination Example</title>


<body bgcolor="">
<s:form action="student">

<display:table id="students" name="students" pagesize="2" export="false" requestURI="/student">
<display:column property="studentRoll" title="Roll" paramId="studentRoll" sortable="true"/>
<display:column property="studentName" title="Name" sortable="true"/>
<display:column property="studentCourse" title="Course" sortable="true" />
<display:setProperty name="paging.banner.placement" value="bottom" />


package net.roseindia;


public class StudentBean implements Serializable{
	String studentName;
	String studentRoll;
	String studentCourse;
	StudentBean(String name, String roll, String course){
	public String getStudentName() {
		return studentName;
	public void setStudentName(String studentName) {
		this.studentName = studentName;
	public String getStudentRoll() {
		return studentRoll;
	public void setStudentRoll(String studentRoll) {
		this.studentRoll = studentRoll;
	public String getStudentCourse() {
		return studentCourse;
	public void setStudentCourse(String studentCourse) {
		this.studentCourse = studentCourse;

package net.roseindia;

import java.awt.List;
import java.util.ArrayList;

import com.opensymphony.xwork2.ActionSupport;

public class StudentAction extends ActionSupport{
private static final long serialVersionUID = 1L;

private java.util.List<StudentBean> students=null;
private List selectStudent=null;

public String execute() throws Exception {
// TODO Auto-generated method stub
java.util.List<StudentBean> students=new ArrayList<StudentBean>();
students.add(new StudentBean("John","1","B.Tech"));
students.add(new StudentBean("Jony","2","M.Tech"));
students.add(new StudentBean("Mark Voucher","3","B.Tech"));
students.add(new StudentBean("Sandy","4","B.Tech"));
students.add(new StudentBean("Sancy Decosta","5","MCA"));
students.add(new StudentBean("Rithus Johny","6","M.Tech"));
students.add(new StudentBean("Kotansy","7","MCA"));
students.add(new StudentBean("Rans Conhty","8","B.Tech"));
students.add(new StudentBean("Reithom","9","M.Tech"));
students.add(new StudentBean("Kathy Seri Kotaan","10","B.Tech"));
return SUCCESS;

public List getSelectStudent() {
return selectStudent;

public void setSelectStudent(List selectStudent) {
this.selectStudent = selectStudent;

public java.util.List<StudentBean> getStudents() {
return students;

public void setStudents(java.util.List<StudentBean> students) {
this.students = students;


<?xml version="1.0" encoding="UTF-8" ?>
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"


<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />

<package name="roseindia" namespace="/" extends="struts-default">

<default-action-ref name="paging" />

<action name="student" class="net.roseindia.StudentAction">
<result name="success">/jsp/displayStudent.jsp</result>



When you run this application it will display message as shown below:


Download this example code

Related Tags for Pagination example in Struts 2.2.1:




Advertisement null