日期:2014-05-17  浏览次数:20650 次

jsp 分页问题 点击下一页的时候 参数传进去了 但是点击的时候无法分页
<%@ page contentType="text/html;charset=GBK" language="java" import="java.sql.*,java.util.*" errorPage="" %>
<html>
<%@ include file="top.jsp"%>

<link href="css.css" rel="stylesheet" type="text/css">


          <div align="center">
            <center> 


          <table width="778" border="0" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="#111111">
            <tr> 
                    <td width="0%" height="25" bgcolor="#DBC2B0" align="center">
                    <font color="#FFFFFF"><b>新闻热点</b></font></td>
                  </tr>
             
   <%
String mypage;
int intpage=1;
mypage=request.getParameter("page");
if(mypage=="")
intpage=1;
if(!mdb.IsInt(mypage))
intpage=1;
if(mdb.IsInt(mypage))
intpage=Integer.parseInt(mypage);
if(intpage<1)
intpage=1;
mypage=Integer.toString(intpage);
int curIndex=1;
int PageSize =10; //设置每张网页显示10条记录
int ShowPage = 1; //设置欲显示的页数
int RowCount = 0; //ResultSet的记录数目
int PageCount = 0; //ResultSet分页后的总页数
int duoyu=0;
RowCount=mdb.getCount("Select count(*) as count from news order by news_ID DESC");
   System.out.println(RowCount);
    duoyu=RowCount % PageSize;
   System.out.println(duoyu+"llllllllllllll");
   System.out.println(RowCount+"ddddddddd");
   System.out.println(PageSize+"eeeeeeeeee");
    if(duoyu==0)
    {
   PageCount=RowCount/PageSize;
    }
    else{
   PageCount=(RowCount-duoyu)/PageSize;
   PageCount++;
    }
ShowPage=intpage;
    if(ShowPage>PageCount)
    {
ShowPage=PageCount;
    }
    else if(ShowPage<=0)
    { 
ShowPage = 1;
    }
curIndex=(ShowPage - 1)*PageSize;
if(curIndex==0){
curIndex=-1;
}
//计算欲显示页的第一笔记录位置
%>                       
  <!----------------------one showing unit------------------------------->
<%
 //利用For循环配合PageSize属性输出一页中的记录
   int i=1,news_id,li