免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1119 | 回复: 1
打印 上一主题 下一主题

希望哪为同志能帮我看看!感激不尽 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-07-17 15:25 |只看该作者 |倒序浏览
我在用jsp尝试做程序的时候,用到了根据时间查询,将查询的结果分页显示出来!当我选择了时间后进行查询,结果第一面的结果能显示出来,可是想翻页就不好使了






代码如下:
<%@ page contentType="text/html;charset=gb2312" %>;
<html>;
<head>;
<title>;逾期的维修项目内容</title>;
<link rel=stylesheet href="../style.css" type="text/css">;

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

</head>;
<body leftmargin="0">;
<script LANGUAGE="javascript">;
function submit10()
{
self.location.replace("rsnormalequry1.jsp"
}
</script>;
<center>;<p>;<h4>;<b>;<font face="楷体_GB2312" size="5" color="#0099FF">;逾期维修项目内容管理</font>;</b>;</h4>;
<%@ page language="java" import="java.sql.*" %>;
<jsp:useBean id="normalview" scope="page" class="opendb.opendb" />;
<%
String year =request.getParameter("year";
String day= request.getParameter("day";           我总觉得问题出在这里,可就是不会解决,希望指点
String mounth=request.getParameter("mounth";
String date=year+mounth+day;
%>;
<%
//指定行数
int pageLine=10;
int totalRec=0;
int totalSub=0;
int intPage=1;
int i;
if (request.getParameter("page"!=null)
intPage=Integer.parseInt(request.getParameter("page");

try{
ResultSet countrs=null;

//取得总记录数
countrs=normalview.executeQuery("select count(*) as cnt from ITEMINFO  where NAME='" + session.getValue("realname" + "' and NEXTDATE >; to_date('" + date + "','yyyyMMdd')";
String rowid;
if (countrs.next())
totalRec=countrs.getInt("cnt";
countrs.close();
normalview.closeStmt();

}
catch(Exception e){
   e.printStackTrace();
}

//取得总页数
int intPageCount=0;
intPageCount = (totalRec+pageLine-1) / pageLine;
%>;
<%
ResultSet RS = normalview.executeQuery("SELECT ROWNUM,EQUIPNAME,ITEMNAME,ITEMPROTY,ITEMCIRCLE,WORKINGTIME,NAME,ASSINAME,MEMO,SELECT_SIGN,TO_CHAR(PREDATE),TO_CHAR(NEXTDATE) FROM ITEMINFO where NAME='" + session.getValue("realname" + "' and NEXTDATE >; to_date('" + date + "','yyyyMMdd')");
String rowid;
String equipname;
String itemname;
String itemproty;
String itemcircle;
String workingtime;
String name;
String assiname;
String memo;
String select_sign;
String predate;
String nextdate;

%>;
<table border='1' cellspacing='0' width='901' bgcolor='#99CCFF' bordercolorlight='#008000' bordercolordark='#ECF5FF' height="43">;
<tr bgcolor='#c8cc98' align='center'>;
  <td width ='17' bgcolor="#99CCFF" height="17">;<font size="2">;序号</font>;</td>;
   <td width ='145' bgcolor="#99CCFF" height="17">;<font size="2">;设备名称</font>;</td>;
   <td width ='102' bgcolor="#99CCFF" height="17">;<font size="2">;项目内容</font>;</td>;
   <td width ='58' bgcolor="#99CCFF" height="17">;<font size="2">;项目属性</font>;</td>;
   <td width ='35' bgcolor="#99CCFF" height="17">;<font size="2">;周期</font>;</td>;
   <td width ='52' bgcolor="#99CCFF" height="17">;<font size="2">;实施时间</font>;</td>;
   <td width ='55' bgcolor="#99CCFF" height="17">;<font size="2">;岗位人员</font>;</td>;
   <td width ='52' bgcolor="#99CCFF" height="17">;<font size="2">;协力方</font>;</td>;
   <td width ='149' bgcolor="#99CCFF" height="17">;<font size="2">;备注</font>;</td>;
</center>;                        
   <td bgcolor="#99CCFF" height="17" width="76">;
    <p align="left">;<font size="2">;上次检修时间</font>;</p>;
</td>;
<center>;
   <td bgcolor="#99CCFF" height="17" width="76">;<font size="2">;预计检修时间</font>;</td>;
      <td width ='34' bgcolor="#99CCFF" height="17">;<font size="2">;选择</font>;</td>; </tr>;
<%
if (intPageCount>;0)
{
           for(i=1;i<=(intPage-1)*pageLine;i++)
                        RS.next();
           for(i=1;i<=pageLine;i++) {
                        if (RS.next()) {
    rowid=RS.getString("ROWNUM");
    equipname=RS.getString("EQUIPNAME");
    itemname=RS.getString("ITEMNAME");
    itemproty=RS.getString("ITEMPROTY");
    itemcircle=RS.getString("ITEMCIRCLE");
    workingtime=RS.getString("WORKINGTIME");
    name=RS.getString("NAME");
    assiname=RS.getString("ASSINAME");
    memo=RS.getString("MEMO");
    select_sign=RS.getString("SELECT_SIGN");
    predate=RS.getString("TO_CHAR(PREDATE)");
    nextdate=RS.getString("TO_CHAR(NEXTDATE)");
%>;
<tr>;
<td width='17' align='center' bgcolor="#E7F1FA" height="18">;<font size="2">;<%=rowid%>;</td>;
<td width='145' align='center' bgcolor="#E7F1FA" height="18">;<font size="2">;<%=equipname%>;</td>;
<td width='102' align='center' bgcolor="#E7F1FA" height="18">;<font size="2">;<%=itemname%>;</td>;
<td width='58' align='center' bgcolor="#E7F1FA" height="18">;<font size="2">;<%=itemproty%>;</td>;
<td width='35' align='center' bgcolor="#E7F1FA" height="18">;<font size="2">;<%=itemcircle%>;</td>;
<td width='52' align='center' bgcolor="#E7F1FA" height="18">;<font size="2">;<%=workingtime%>;</td>;
<td width='55' align='center' bgcolor="#E7F1FA" height="18">;<font size="2">;<%=name%>;</td>;
<td width='52' align='center' bgcolor="#E7F1FA" height="18">;<font size="2">;<%=assiname%>;</td>;
<td width='149' align='center' bgcolor="#E7F1FA" height="18">;<font size="2">;<%=memo%>;</td>;
<td width='76' align='center' bgcolor="#E7F1FA" height="18">;<font size="2">;<%=predate%>;</td>;
<td width='76' align='center' bgcolor="#E7F1FA" height="18">;<font size="2">;<%=nextdate%>;</td>;
<td width='34' align='center' bgcolor="#E7F1FA" height="18">;<a href="select.jsp?id=<%=equipname%>;" onClick="return newwin(this.href);">;<font size="2">;选择</font>;</a>;</td>;

</tr>;
<%
  }
}
RS.close();
}
%>;
<!--以下用于分页显示 -->;
<%
out.print("<tr>;");  
if (intPageCount*pageLine<totalRec)
   intPageCount++;
if (intPage>;intPageCount )
                intPage=intPageCount;
if (intPage < 1 )
                intPage=1;
                out.print("<form method='POST'  name=fPageNum  action='rsnormalequry1.jsp'>;");
                out.print("<p align='left'>;&amp;&amp;分页&amp;");
         
          if (intPage<2)
                    out.print("<font color='999966'>;首页 上一页</font>;&amp;");
          else{   
                  out.print("<a href='rsnormalequry1.jsp?page=1'>;首页</a>;&amp;");   
                    out.print("<a href='rsnormalequry1.jsp?page=" + (intPage-1) + "'>;上一页</a>;&amp;"   );
            }
         
            
          if( intPage-intPageCount>;=0 )
                    out.print("<font color='999966'>;下一页 尾页</font>;"   );
          else{   
                 
                    out.print("<a href='rsnormalequry1.jsp?page="+(intPage+1)+"'>;下一页</a>; <a href='rsnormalequry1.jsp?page=" + intPageCount + "'>;尾页</a>;");
            }

        out.print("&amp;页次:<strong>;<font color=red>;"+intPage+"</font>;/"+intPageCount+"</strong>;页 "   );
           out.print("&amp;共<b>;"+totalRec+"</b>;条记录 <b>;"+pageLine+"</b>;条/页 "   );
           out.print(" 转到第<input type='text' name='page' size=2 maxlength=10 class=smallInput value="+intPage+">;");   
           out.print("页<input class=buttonface type='submit'  value='GO'  name='cndok'>;</span>;</p>;</form>;"  );

        out.print("</td>;");
        out.print("</tr>;");
       
%>;

</table>;
<a href="javascript:window.close();">;[关闭]</a>;
</center>;                                                                                                                        

</html>;

论坛徽章:
0
2 [报告]
发表于 2004-07-17 17:22 |只看该作者

希望哪为同志能帮我看看!感激不尽

大家帮帮我撒!没有人回答的话,我强烈要求版主给我解答一下撒,要不你就介绍个同志帮忙解答解答撒!谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP