您的位置:程序门 -> java ->



100分求救:jsp的sqlserver2000分页问题,从数据库中读数据并分页显示,搞一周都没明白


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


100分求救:jsp的sqlserver2000分页问题,从数据库中读数据并分页显示,搞一周都没明白[无满意答案结贴,结贴人:t_ianya]
发表于:2007-06-10 16:02:19 楼主
我的目的是要从数据库中读取数据,并且能够分页显示出来
但是结果却什么都没显示,
jbuilder2006+sqlserver2000
程序如下:
<!doctype   html   public "-//w3c//dtd   html4.0   transitional//en ">
<%@   page   import= "java.sql.*,java.lang.* "   language= "java "%>
<%@   page   contenttype= "text/html;   charset=gb2312 "     import= "com.am.* "%>
<jsp:usebean   id= "dbconn "   scope= "page "   class= "com.am.opendb "/>
<%@page   import= "java.util.vector,com.am.page "%>

<html>
<head>
<style   type= "text/css ">
<!--
body   {   font-size:   9pt;   font-family:   宋体   }
.style1   {color:   red}
.style2   {color:   #6666ff}
-->
</style>
<title>
监控查询页面
</title>
</head>
<body   bgcolor= "#ffffff ">
<%@   include   file= "navigate.jsp "%>
<%
try{
string   getpage=request.getparameter( "pageid ").trim();
if(getpage.compareto( "-1 ")==0)
{   //分页准备工作,保存分页信息
        string   sql= "select   pid   from   signal ";
    resultset   rs=dbconn.EXECutequery(sql);
  page   mypage=new   page();
    mypage.recordcount=0;
    mypage.pagesize=10;
    mypage.pagecount=0;
    mypage.pageid=1;

    vector   idlist=new   vector();
    getpage= "1 ";
while(rs.next())
    {
   
        mypage.recordcount++;
                if(mypage.recordcount==mypage.pagesize)
                {
                          mypage.pagecount++;
                          idlist.addelement(rs.getstring( "pid "));
                          mypage.recordcount=0;
                  }
      }
    if(mypage.recordcount!=0)   {mypage.pagecount++;}
    mypage.recordcount+=(mypage.pagecount-1)*mypage.pagesize;
        rs.close();
    session.setattribute( "idlist ",idlist);
    session.setattribute( "mypage ",mypage);
}
%>
<%
         
        boolean   pageerror=false;
      page   mypage=(page)session.getattribute( "mypage ");
        //查询结果为空
        if(mypage.recordcount <=0)
        {%> 对不起,没有找到您所需要的信息,请扩大查询范围! <%}
        else
        {
                    //查询结果不为空
                  int   pageid=mypage.pageid;
                  if(getpage!=null&&getpage!= " ")
                  {pageid=integer.parseint(getpage.trim());}

                  if(pageid <1 ¦ ¦pageid> mypage.pagecount)
                  {
                          //输入的页码超出范围
                          pageid=mypage.pageid;
                          pageerror=true;
                    }
                  mypage.pageid=pageid;
                vector   idlist=(vector)session.getattribute( "idlist ");
                string   getlist= " ";
                if(pageid> 1)
                {
                          getlist=(string)idlist.elementat(pageid-2);
                          getlist= "and   pid < "+getlist;
                  }
                  string   sql= "select   top "+mypage.pagesize+ "*   from   signal ";
                  sql=sql+getlist;
                  resultset   rs=dbconn.EXECutequery(sql);
%> <br>
<table   width= "540 "   border= "0 ">
          <tr>
                <td   width= "25% "> <b> <font   color= "#ff0000 "> </font> </b> 共有记录 <b> <font   color= "#ff0000 "> <%=mypage.recordcount%> </font> </b> 条
            </td>
                <td   width= "30% "> <%if(pageerror){%> 你输入的页码无效 <%}%> </td>
                <td   width= "45% "> 共有 <b> <font   color= "#ff0000 "> <%=mypage.pagecount%> </font> </b> 页,现在显示的是第
            <b> <font   color= "#ff0000 "> <%=mypage.pageid%> </font> </b> 页
                      </td>
            </tr>
</table>
            <table   width= "540 "   border= "0 ">
                    <tr   bgcolor= "#ff5d26 ">
                          <td   width= "42 ">
                                    <div   align= "center "> <font   color= "#ffffff "> 记录数 </font> </div>
                          </td>
                          <td   width= "150 ">
                                    <div   align= "center "> <font   color= "#ffffff "> 信号名称 </font> </div>
                          </td>
                            <td   width= "80 ">
                                <div   align= "center "> <font   color= "#ffffff "> 当前值 </font> </div>
                              </td>
                          <td   width= "80 ">
                                <div   align= "center "> <font   color= "#ffffff "> 单位 </font> </div>
                              </td>
                        </tr>
<%

                      string   pid;
                      string   signalname;
                      string   signalvalue;
                      string   signalunit;
                      int   wsh=0;
                    while(rs.next())
                    {
                                  wsh++;
                                  pid=rs.getstring( "pid ");
                                  signalname=rs.getstring( "signalname ");
                                  signalvalue=rs.getstring( "signalvalue ");
                                  signalunit=rs.getstring( "signalunit ");
                            %>
                              <tr   bgcolor= "#ffd6c8 ">
                                    <td   width= "42 "   height= "13 ">
                                            <div   align= "center "> <%=wsh+mypage.pagesize*(pageid-1)%> </div>
                                    </td>
                                    <td   width= "133 "   height= "13 ">
                                            <div   align= "center "> <%=signalname%> </div> </td>
                                    <td   width= "113 "   height= "13 ">
                                              <div   align= "center "> <%=signalvalue%> </div>
                                    </td>
                                    <td   width= "126 "   height= "13 "   bgcolor= "#ffd6c8 ">
                                            <div   align= "center "> <%=signalunit%> </div>
                                    </td>
                              </tr>
                <%}
                  rs.close();
%>
                </table>
              <table   width= "540 "   border= "0 ">
                      <tr>
                                  <td   width= "133 "> &nbsp; </td>
                                <td   width= "397 ">
                                        <form   name= "form1 "   action= "supervision.jsp "   method= "post "   onsubmit= "return   checkform(this); ">
        <%
            if(pageid!=1)
                  {//当处于第一页时, "第一页 "和 "上一页 "链接失效;
                    %>
                  <a   href= "supervision.jsp?pageid=1 "> 第一页 </a> ¦ <a   href= "supervision.jsp?pageid= <%=pageid-1%> "> 上一页 </a> ¦ <%}else{%> 第一页 ¦上一页 ¦
                  <%}
                  if(pageid!=mypage.pagecount)
                    {//当处于第一页时, "第一页 "和 "上一页 "链接失效;
                      %>
                    <a   href= "supervision.jsp?pageid= <%=pageid+1%> "> 下一页 </a> ¦
                    <a   href= "supervision.jsp?pageid= <%=mypage.pagecount%> "> 最后一页 </a>
                    <%}else{%>
                    下一页 ¦最后一页
                      <%}%>
                  输入页码:
                                <input   type= "text "   name= "pageid "   size= "5 ">
                                    页数: <b> <font   color= "#ff0000 "> <%=pageid%> </font> </b> /
                                    <b> <font   color= "#ff0000 "> <%=mypage.pagecount%> </font> </b>
                              </form>
                        </td>
                  </tr>
          </table>
        <%}
}catch(exception   e){}%>
</body>
</html>
编译通过,但没有任何结果
请大家帮忙改正
发表于:2007-06-10 23:30:151楼 得分:0
看看
发表于:2007-06-11 12:31:202楼 得分:0
看出来了么?
发表于:2007-06-12 21:52:203楼 得分:0
no   body   tell   me   !
郁闷


快速检索

最新资讯
热门点击