Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:请高手们帮帮我把我的代码写完好吗?? 我想分页已经一周了我真是分不出来了. [Re:SQL20000]
dwju





发贴: 117
积分: 10
于 2003-08-04 18:00 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
<%@ page contentType="text/html; charset=GBK"
import="java.sql.*"
%>

<%
String theType = request.getParameter("setType");
String theStr = "产品展示";
if(theType.equals("zzcp")) theStr="最新产品";
if(theType.equals("cxcp")) theStr="促销产品";
if(theType.equals("rxcp")) theStr="热销产品";
%>
<jsp:useBean id="bean" scope="page" class="com.DBConnection"/>
<%
int rowCount;
int intPage = 1;
int pageCount =1;
if(bean.dbConnection())
{
  /********************************************************
  *这里根据前面传来不同的值,来判断SQL语句
  *然后再执行查询,计算总行数和总的页数
  ********************************************************/
  String query = "select spbm,spmc,spxh,jjsx,lsdj from kc_spzl";
  ResultSet resultset = bean.executeQuery(query);

  resultset.last();
  rowCount = resultset.getRow();
  intPage = 1;
  //转化接收到的页面信息
  String strPage = request.getParameter("page");
  if(strPage==null)
  {
    intPage=1;
  }
  else
  {
    intPage = java.lang.Integer.parseInt(strPage);
    if(intPage<1) intPage=1;
  }

  int pageSize = 12;

  pageCount = 0;
  pageCount = rowCount / pageSize;

  if(intPage>pageCount) intPage=pageCount;
  int j=(intPage-1)*pageSize+1;
  
%>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <link rel="stylesheet" href="css\css.css" type="text/css">
  </head>

  <body bgcolor="#FFFFFF" text="#000000" scroll=no>
    <table width=620 border="0" cellspacing="0" cellpadding="0" bgcolor="#E1E1E1" class="frmBox" align="center">
      <tr>
      <td bgcolor="#003399" height="20"></td>
      </tr>
      <tr>
      <td bgcolor="#999999" align=center>
        <table width="100%" border="0" cellspacing="0" cellpadding="1">
        <tr>
        <td rowspan="2" align="center" width="16%"><img src="file:///F|/Information/Information/img/001.gif" width="32" height="32"></td>
        <td width="84%"><font color="#FFFFFF" size="+1"><b>产品展示</b></font></td>
        </tr>
        <tr>
        <td width="84%"><font color="#FFFFFF">-------<%out.println(theStr);%>

        </font></td>
        </tr>
        </table>
      </td>
      </tr>
      <tr bgcolor="#E1E1E1" height=20><td></td></tr>
      <tr><td align="center">
      <table width=615>
        <tr>
      <td align="left"> </td>
        </tr>
      </table>

<table width=615 border="0" cellspacing="1" cellpadding="0" style="border:2 inset;line-height:3.0" bgcolor="#CCCCCC" >
   <tr bgcolor="#E1E1E1">
       <td width=10% class="ed_btnStyle"><Strong>药品编号</strong></td>
       <td width=25% class="ed_btnStyle"><Strong>药品名称</strong></td>
       <td width=10% class="ed_btnStyle"><Strong>商品型号</strong></td>
       <td width=15% class="ed_btnStyle"><Strong>商品规格</strong></td>
       <td width=20% class="ed_btnStyle"><Strong>零售单价</strong></td>
       <td width=20% class="ed_btnStyle"><Strong>详细信息</strong></td>
      </tr>
<%
/***********************************************************
*利用前面求出的pageCount来为查询叶面分页
* 注意,后面翻页的时候,注意传递不同的查询类型值
***********************************************************/
  int i=0;
  resultset.absolute(j);
  while(i<pageSize && !resultset.isAfterLast())
  {
    String changeSpbm=resultset.getString("spbm");
%>
<tr bgcolor="#FFFFFF">
<td width=5%><%=resultset.getString("spbm")%></td>
<td width=30%><%=resultset.getString("spmc")%></td>
<td width=10%><%=resultset.getString("spxh")%></td>
<td width=15%><%=resultset.getString("jjsx")%></td>
<td width=20%><%=resultset.getString("lsdj")%></td>
<td width=20% align="center"><a href="list.jsp?changeValue=<%=changeSpbm%>">商品详细信息</a> </td>
</tr>
<%
    resultset.next();
    i=i+1;
  }
}
%>
</table>
   <table width=100%>
     <tr>
      <td width="30%">
        第<%=intPage%>页/共<%=pageCount%>页
      </td>
      <td width="70%" align="right">
        <%if(intPage!=1){%>
        <a href="CPZS.jsp?page=1&setType=<%=theType%>">首页</a>
        <%
        }
        else
        {
          out.print("首页");
        }%>
        <%if(intPage>1){%>
        <a href="CPZS.jsp?page=<%=intPage-1%>&setType=<%=theType%>">上一页</a>
        <%
        }
        else
        {
          out.print("上一页");
        }%>
        <%if(intPage < pageCount){%>
        <a href="CPZS.jsp?page=<%=intPage+1%>&setType=<%=theType%>">下一页</a>
        <%
        }
        else
        {
          out.print("下一页");
        }%>
        <%if(intPage!=pageCount){%>
        <a href="CPZS.jsp?page=<%=pageCount%>&setType=<%=theType%>">尾页</a>
        <%
        }
        else
        {
          out.print("尾页");
        }%>
      </td>
    </tr>
   </table>
</td>
</tr>
    </table>
  </body>
</html>

这个是我刚刚做的,应该可以的,
不过我定义Statement的时候好象定义为非只读的不可以
一定要定义成只读的才可以分页,你看看你定义是否是那样的!




话题树型展开
人气 标题 作者 字数 发贴时间
6990 请高手们帮帮我把我的代码写完好吗?? 我想分页已经一周了我真是分不出来了. SQL20000 1919 2003-08-04 17:33
5673 Re:请高手们帮帮我把我的代码写完好吗?? 我想分页已经一周了我真是分不出来了. jimmywin 1847 2003-08-04 17:50
5942 Re:请高手们帮帮我把我的代码写完好吗?? 我想分页已经一周了我真是分不出来了. dwju 4604 2003-08-04 18:00
5783 Re:请高手们帮帮我把我的代码写完好吗?? 我想分页已经一周了我真是分不出来了. SQL20000 32 2003-08-04 18:02
6005 Re:请高手们帮帮我把我的代码写完好吗?? 我想分页已经一周了我真是分不出来了. dwju 323 2003-08-04 18:18
5789 Re:请高手们帮帮我把我的代码写完好吗?? 我想分页已经一周了我真是分不出来了. SQL20000 38 2003-08-04 21:01
5469 Re:请高手们帮帮我把我的代码写完好吗?? 我想分页已经一周了我真是分不出来了. SQL20000 36 2003-08-05 07:55
5729 Re:请高手们帮帮我把我的代码写完好吗?? 我想分页已经一周了我真是分不出来了. dwju 112 2003-08-05 11:21
5430 Re:请高手们帮帮我把我的代码写完好吗?? 我想分页已经一周了我真是分不出来了. SQL20000 28 2003-08-05 14:27
5679 Re:请高手们帮帮我把我的代码写完好吗?? 我想分页已经一周了我真是分不出来了. dwju 9 2003-08-05 17:11

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923