81,092
社区成员
发帖
与我相关
我的任务
分享
<%
FlowCardService flowCardService = (FlowCardService)this.getServletContext().getAttribute(FlowCardService.class.getName());
int pageNo = 1;
int pageSize = 2;
String clientId = request.getParameter("clientId");
if (clientId == null) {
clientId = "";
}
String clientName = request.getParameter("clientName");
if (clientName == null) {
clientName = "";
}
String beginDate = request.getParameter("beginDate");
if (beginDate == null) {
beginDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
}
String endDate = request.getParameter("endDate");
if (endDate == null) {
endDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
}
PageModel pageModel = flowCardService.findAllFlowCard(pageNo, pageSize, clientId, beginDate, endDate);
String queryCon = "&clientId=" + clientId + "&clientName=" + clientName + "&beginDate=" + beginDate + "&endDate=" + endDate;
System.out.println(queryCon);
%>
//JavaScript中的相关代码
function topPage() {
window.self.location = "flow_card_maint.jsp?pageNo=1<%=queryCon%>";
}
function previousPage() {
window.self.location = "flow_card_maint.jsp?pageNo=<%=pageModel.getPreviousPageNo()%><%=queryCon%>";
}
function nextPage() {
window.self.location = "flow_card_maint.jsp?pageNo=<%=pageModel.getNextPageNo()%><%=queryCon%>";
}
function bottomPage() {
window.self.location = "flow_card_maint.jsp?pageNo=<%=pageModel.getBottomPageNo()%><%=queryCon%>";
}
function queryFlowCard() {
with(document.forms[0]) {
action="flow_card_maint.jsp";
method="post";
submit();
}
}
String pageNoStr = request.getParameter("pageNo");
if (pageNoStr != null && !"".equals(pageNoStr)) {
pageNo = Integer.parseInt(pageNoStr);
}
,不过还是感谢大家的帮忙!public class PageModel {
private List list;
private int totalRecords;
private int pageSize;
private int pageNo;
public List getList() {
return list;
}
public void setList(List list) {
this.list = list;
}
public int getTotalRecords() {
return totalRecords;
}
public void setTotalRecords(int totalRecords) {
this.totalRecords = totalRecords;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
/**
* 总页数
* @return
*/
public int getTotalPages() {
return (this.totalRecords + this.pageSize -1)/this.pageSize;
}
/**
* 上一页
* @return
*/
public int getPreviousPageNo() {
if(this.pageNo <= 1) {
return 1;
}
return this.pageNo - 1;
}
/**
* 下一页
* @return
*/
public int getNextPageNo() {
if (this.pageNo >= this.getBottomPageNo()) {
return this.getBottomPageNo();
}
return this.pageNo + 1;
}
/**
* 尾页
* @return
*/
public int getBottomPageNo() {
return this.getTotalPages();
}
}
这个在其他页面都分页成功过。[/quote]
int pageNo = 1;
int pageSize = 2;
别放在这个页面里边,放在你实现分页的方法里边,如果页面传页码到后台了就用传来的页码,没传默认就是第一页,你现在每次一加载页面pageNo都是1.public class PageModel {
private List list;
private int totalRecords;
private int pageSize;
private int pageNo;
public List getList() {
return list;
}
public void setList(List list) {
this.list = list;
}
public int getTotalRecords() {
return totalRecords;
}
public void setTotalRecords(int totalRecords) {
this.totalRecords = totalRecords;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
this.pageNo = pageNo;
}
/**
* 总页数
* @return
*/
public int getTotalPages() {
return (this.totalRecords + this.pageSize -1)/this.pageSize;
}
/**
* 上一页
* @return
*/
public int getPreviousPageNo() {
if(this.pageNo <= 1) {
return 1;
}
return this.pageNo - 1;
}
/**
* 下一页
* @return
*/
public int getNextPageNo() {
if (this.pageNo >= this.getBottomPageNo()) {
return this.getBottomPageNo();
}
return this.pageNo + 1;
}
/**
* 尾页
* @return
*/
public int getBottomPageNo() {
return this.getTotalPages();
}
}
这个在其他页面都分页成功过。