当前位置: 代码迷 >> Java Web开发 >> 大哥大姐求助啊~~新手问题
  详细解决方案

大哥大姐求助啊~~新手问题

热度:93   发布时间:2005-12-02 14:17:00.0
大哥大姐求助啊~~新手问题

我有一个JSP+SQLServer2000分页显示页面,为什么不能显示第一页以后的内容啊,帮帮忙啊!!



<%@ page contentType="text/html;charset=GB2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.util.*" %>
<html>
<head>
<title>药品查询</title>
<body>
<form name="xuncha" method="post" action="ypcx.jsp">
<table width="900" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="20" colspan="7">生产厂家:<input name="sccj" type="text" size="20">&nbsp;药品名称:<input name="ypmc" type="text" size="20">&nbsp;拼音查询:<input name="pycx" type="text" size="20">&nbsp;批号查询:<input name="phcx" type="text" size="10"><input type="submit" value="GO">
</td>
</tr>
<tr>
<td width="126" height="20"><div align="center">药品名称</div></td>
<td width="126"><div align="center">生产厂家</div></td>
<td width="127"><div align="center">规格</div></td>
<td width="126"><div align="center">包装</div></td>
<td width="126"><div align="center">单位</div></td>
<td width="126"><div align="center">批号</div></td>
<td width="127"><div align="center">单价</div></td>
</tr>
<%
String url="jdbc:odbc:scjl";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection(url,"sa","");
Statement sten=conn.createStatement();
int pages;
int allpage; //总页面数
int ipage=2; //每页显示记录数
int record; //总记录数
int userpage; //自定义页面数
int cpage=1; //当前显示页面数
int spage; //当前记录位置
int i; //循环变量
String sccj1=request.getParameter("sccj");
String ypmc1=request.getParameter("ypmc");
String pycx=request.getParameter("pycx");
String phcx=request.getParameter("phcx");


if(sccj1==null && ypmc1==null && pycx==null && phcx==null)
{
out.print("没有任何内容");
}
else
{
String sccj=new String(sccj1.getBytes("ISO-8859-1"), "GB2312");
String sel_1="select count(*) as RECORD from yaopin_info where SCCJ like '%"+sccj+"%'";
ResultSet rn_1=sten.executeQuery(sel_1);
rn_1.next();
record=rn_1.getInt("RECORD");
allpage=(int)Math.ceil((record + ipage-1) / ipage);
if(request.getParameter("pages")==null)
{
userpage=1;
}
else
{
userpage=new Integer(request.getParameter("pages")).intValue();
}

if(userpage>allpage)
{
cpage=1;
}
else
{
cpage=userpage;
}
spage=(cpage-1)*ipage;
String sel_2="SELECT ID,YPMC,SCCJ,GUIGE,BAOZHUANG,DANWEI,PIHAO,DANJIA from yaopin_info where SCCJ like '%"+sccj+"%' order by ID";
ResultSet rn_2=sten.executeQuery(sel_2);
for(int j=1;j<spage;j++)
rn_2.next();
if(record==0)
out.println("没有记录");
else
{
i=0;
while(i<ipage && rn_2.next())
{
String ypmc=rn_2.getString("YPMC");
String Sccj=rn_2.getString("SCCJ");
String guige=rn_2.getString("GUIGE");
String baozhuang=rn_2.getString("BAOZHUANG");
String danwei=rn_2.getString("DANWEI");
String pihao=rn_2.getString("PIHAO");
String danjia=rn_2.getString("DANJIA");
%>
<tr bordercolor="#FFFFFF" bgcolor="#6699CC">
<td width="126" align="center"><%=ypmc%></td>
<td width="126" align="center"><%=Sccj%></td>
<td width="127" align="center"><%=guige%></td>
<td width="126" align="center"><%=baozhuang%></td>
<td width="126" align="center"><%=danwei%></td>
<td width="126" align="center"><%=pihao%></td>
<td width="127" align="center"><%=danjia%></td>
<%
i++;
}
}
%>
<tr bordercolor="#993300" bgcolor="#006699">
<td colspan="7" align="right" valign="middle"><span class="style3 style3">共<%=record%>条记录 共<%=allpage%>页
<%
if(cpage>1)
{
%>
<a href="ypcx.jsp?pages=<%=cpage-1%>">上一页</a>
<%
}
if(cpage<allpage)
{
%>
<a href="ypcx.jsp?pages=<%=cpage+1%>">下一页</a>
<%
}
%>
转到第
<%
for(i=1;i<=allpage;i++)
{
if(i<(cpage+10))
{
%>
<a href="pycx.jsp?pages=<%=i%>"><%=i%></a>
<%
}
}
}
%>

</table>
</form>
</body>
</html>

搜索更多相关主题的帖子: 大姐  

----------------解决方案--------------------------------------------------------
  相关解决方案