为什么我的分页不能运行??
我作了一个struts的分页程序,可以显示第一页和 "下一页 "链接,可是在点击 "下一页 "运行时就出差了,调试发现是页面的数据没有传回Action,请问各们大虾这是怎么回事,小弟我弄了好久了呀.....
源码如下:
数据库mysql:
create table book(name varchar(50), author varchar(30), price int);
bean:(其中PageBean用于处理分页)
Book.java
public class Book {
private String bookName;
private String author;
private int price;
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getBookName() {
return bookName;
}
public void setBookName(String bookName) {
this.bookName = bookName;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
}
PageBean.java
import
java.sql.SQLException;
import java.util.ArrayList;
public class PageBean {
private static int record = 5;
private int currentPage = 1;
private int totalPages = 0;
private int totalRecords = 0;
private int pageStart = 0;
private int pageEnd = 0;
private boolean hasNext = false;
private boolean hasPrev = false;
private static ArrayList list;
public PageBean() {
}
public PageBean(ArrayList list) {
this.list = list;
totalRecords = list.size();
setCurrentPage(1);
setTotalPages();
setPageStart();
setPageEnd();
setHasNext(true);
}
public Book[] getPreviousPage() {
if (currentPage < totalPages) {
hasNext = true;
} else
hasNext = false;
currentPage -= 1;
if (currentPage <= 0) {
currentPage = 1;
hasPrev = false;
} else
hasPrev = true;
pageStart = (currentPage - 1) * record + 1;
pageEnd = pageStart + record - 1;
return getBooks();
}
public Book[] getNextpage() {
if (currentPage - 1 > 0) {
hasPrev = true;
} else
hasPrev = false;
currentPage += 1;
if (currentPage > totalPages) {
currentPage = totalPages;
hasNext = false;
} else {
hasNext = true;
pageStart = (currentPage - 1) * record + 1;
if (currentPage == totalPages) {
pageEnd = totalRecords;
} else {
pageEnd = pageStart + record - &n