StringBuffer sql = new StringBuffer("");
      sql.append(
          "select * from (select temp.*,rownum num from (");
      sql.append(sqlStatement);
      sql.append(") temp) where num between ? and ?");

解决方案 »

  1.   

    找hibernate的源代码,其中有。
      

  2.   

    <<<
    StringBuffer sql = new StringBuffer("");
          sql.append(
              "select * from (select temp.*,rownum num from (");
          sql.append(sqlStatement);
          sql.append(") temp) where num between ? and ?");
    >>>
    如果需要排序呢?
    而且这种方法效率极低.试一下两万条记录,再加上两三个join,估计得花上个几十秒的。
    把SQL改成:
    select * from (select *,rownum from (your sqlStatement) where rownum<nEnd minus 
    select *,rownum from (your sqlStatement) where rownum<nStart )
    另外要取出排序字段名,用别名处理.
      

  3.   

    select table.id,num
    from (select table.id,rownum num 
          from (select table.id
                from table order by id))
    where num between startnum and endnum;
      

  4.   

    <%@ page contentType="text/html; charset=GBK" %>
    <%@ page language="java" %>
    <%@ taglib uri="/WEB-INF/taglib/struts-logic.tld" prefix="logic" %>
    <%@ taglib uri="/WEB-INF/taglib/struts-bean.tld"  prefix="bean" %>
    <%@ taglib uri="/WEB-INF/taglib/struts-html.tld"  prefix="html" %>
    <html:html>
    <head>
    <title>
    Login Success!
    </title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head>
    <html:form action="/edit">
    <body bgcolor="#FFFFFF" text="#000000">
        <table width="70%" cellpadding="0" cellspacing="0" style="" align="center">
        <!--判断list是否存在,如果不存在显示无信息-->
            <logic:notPresent name="list">
              <tr><td>无信息</td></tr>
            </logic:notPresent>32
        </table>
        <!--判断list是否存在,如果存在,则执行下面的代码,如果不存在则跳过-->
        <logic:present name="list">
            <XML ID="xmlParts">
              <?xml version="1.0" ?>
                 <parts>
                 <!--循环输出变量名称为list中得数据 taskList是循环的临时变量 type指定list中的每个实例的类型-->
                   <logic:iterate name="list" id="taskList" scope="request" type="******.SucessVO">
                       <part>
                            <username>      <bean:write name="taskList" property="stuName"/<!--stuName 是SucessVO类中的成员变量名称-->> </username>
                              <userage>       <bean:write name="taskList" property="stuAge"/<!--stuAge 是SucessVO类中的成员变量名称-->>   </userage>
                              <usersex>       <bean:write name="taskList" property="stuSex"/<!--stuSex 是SucessVO类中的成员变量名称-->>   </usersex>
                          </part>
                      </logic:iterate>
               </parts>
            </XML>
       
            <div style="height:200px;">
                <table border="10" cellpadding="2" cellspacing="0" datasrc=#xmlParts id="tb1" datapagesize="5">
                 <tr>
                  <td><input type=radio name=chk onclick="this.value = this.nextSibling.value"><input type=hidden datafld=username></td>
                  <td><a href="#" onclick="alert(this.chilren[0].innerText)"><div datafld="username"></div></td>
              <td><div datafld="userage"></div></td>
        <td><div datafld="usersex"></div></td>
                    </tr>
                </table>
          </div>
          <INPUT type="button" value=" << " onClick="tb1.firstPage()">
          <INPUT type="button" value=" < " onClick="tb1.previousPage()">
          <INPUT type="button" value=" > " onClick="tb1.nextPage()">
          <INPUT type="button" value=" >> " onClick="tb1.lastPage()">
       </logic:present>
     
       <input type=button value="commit" onclick="test()">
       <script>
           function test()
           {
               var oChk = document.all.chk;
               for(var i=0;i<oChk.length; i++)
              if(oChk[i].checked)
               {
               alert(oChk[i].value)
               document.forms[0].submit();
             }
             
       }
       </script> 
    </body>
    </html:form>
    </html:html>
      

  5.   

    我不知道是否理解你的意思,如果单单就是分页显示,用Dreamweaver很容易的做出来。
      

  6.   

    你说的是从数据库里查找出想要的内容,然后把它分页显示出来吧,
    我以前倒是做过一个,不过一个装linux的时候不小心搞丢了,
    给你点建议吧,你自己做这个时候把那个几变量搞明白就行了,不要照般事例
      

  7.   

    JMaxius(J.Maxius)谢谢你我是从ORACLE数据库中显示出我想查找的内容,但是内容太多,所以想分页显示
      

  8.   


    <%
    /*传递变量说明
    totalCount:总计录;pageURL:本页;pageCommonLink:共同链接
    */ String pages=request.getParameter("pages"); //取当前页数
    int pageCount=0;    //定义页数及每页显示数目
    int pageInt=1;
    if(pages==null)pageInt=1;           //没有点击页数
    else
    {
    pageInt=Integer.parseInt(pages);
    }
    pageCount=(totalCount%displayCount==0)?totalCount/displayCount:totalCount/displayCount+1;
    int beginI=(pageInt-1)*displayCount+1;
    int endI=(pageInt*displayCount>totalCount)?totalCount:pageInt*displayCount;
    %>
    <style type="text/css">
    a.fontColors:link {
    font-size: 12px;
    color: #003366;
    text-decoration: none;
    }
    a.fontColors:visited {
    font-size: 12px;
    color: #003366;
    text-decoration: none;
    }
    a.fontColors:hover {
    font-size: 12px;
    color: #003366;
    text-decoration: underline;
    }
    a.fontColors:active {
    font-size: 12px;
    color: #003366;
    text-decoration:none;
    }
    </style>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
      <tr> 
        <td width="35%"> <div align="center"><font color="003366" style="font-size:12px">共有<%=totalCount%>条,目前是第<%=pageInt%>页</font></div></td>
        <td width="13%"> <div align="center"> 
            <%if(pageInt>1){%>
            <a class="fontColors" href="<%=pageURL%>?pages=1<%=pageCommonLink%>">第一页</a> 
            <%}%>
          </div></td>
        <td width="10%"> <div align="center"> 
            <%if(pageInt>1){%>
            <a class="fontColors" href="<%=pageURL%>?pages=<%=pageInt-1%><%=pageCommonLink%>">上一页</a> 
            <%}%>
          </div></td>
        <td width="10%"> <div align="center"> 
            <%if(pageInt<pageCount){%>
            <a class="fontColors" href="<%=pageURL%>?pages=<%=pageInt+1%><%=pageCommonLink%>">下一页</a> 
            <%}%>
          </div></td>
        <td width="10%"> <div align="center"> 
            <%if(pageInt<pageCount){%>
            <a class="fontColors" href="<%=pageURL%>?pages=<%=pageCount%><%=pageCommonLink%>">最后页</a> 
            <%}%>
          </div></td>
        <td width="22%"><div align="right"><font color="#003366" style="font-size:12px">转到 </font><select id="xPages2" style="height:18;font-size:9pt" onChange="javascript:self.location='<%=pageURL%>?pages='+xPages2.options[xPages2.selectedIndex].value+'<%=pageCommonLink%>&temps=<%=System.currentTimeMillis()%>'">
     <%for(int i=1;i<=pageCount;i++){%>
              <option value="<%=i%>" <%=(pageInt==i)?"selected":""%>><%=i%></option>
     <%}%>
            </select><font color="#003366" style="font-size:12px"> 页</font></div></td>
      </tr>
    </table>
      

  9.   

    完整的例子你写信给我,我发给你
    [email protected]