sun7bear
发贴: 16
积分: 0
|
于 2006-05-07 15:57
PageBean.java: package com.jspdev.page; import java.util.Vector; public class PageBean {
/** * @param args */ public int curPage; // 当前是第几页
public int maxpage; // 一共有多少页
public int maxRowCount; // 一共有多少行
public int rowsPerPage = 5; // 每页多少行
public Vector data; // 本页要显示的资料
public void countMaxPage() {// 根据总行数计算总页数
if (this.maxRowCount % this.rowsPerPage == 0) { this.maxpage = this.maxRowCount / this.rowsPerPage; } else { this.maxpage = this.maxRowCount / this.rowsPerPage + 1; } }
public Vector getResult() { return this.data; }
public PageBean(ContactBean contact) throws Exception { this.maxRowCount = contact.getAvailableCount();// 得到总行数 this.data = contact.getResult(); this.countMaxPage(); }
} contact.jsp: <jsp:useBean id="pageCtl" class="com.jspdev.page.PageBean" scope="request"/> <table border=1> <% java.util.Vector v = pageCtl.getResult(); java.util.Enumeration e = v.elements(); while(e.hasMoreElements()) { Object[] obj=(Object[])e.nextElement(); %> <tr> <td align="center" width="95"><%= obj[0] %></td> <td align="center" width="93"><%= obj[1]%></td> <td align="center" width="71"><%= obj[2] %></td> <td align="center" width="142"><%= obj[3] %></td> <td align="center" width="142"><%= obj[4] %></td> <td align="center" width="142"><%= obj[5] %></td> </tr> <%}%> </table> <%if(pageCtl.maxpage !=1){%> <form name="PageForm" action="/page/servlet/contactservlet" method="post"> <%@ include file="/pageman.jsp"%> </form> <%}%> 可是我放在PageBean中,然后运行contact.jsp,怎么报如下错误呢? org.apache.jasper.JasperException: /contact.jsp(1,1) The value for the useBean class attribute com.jspdev.page.PageBean is invalid. org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
|