dwju
发贴: 117
积分: 10
|
于 2003-08-02 16:13
这里只是一个JSP页面,调用了一个JavaBean, <%@ 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="wlsd.DBConnection"/> <% int rowCount; int intPage = 1; int pageCount =1; if(bean.dbConnection()) { /******************************************************** *这里根据前面传来不同的值,来判断SQL语句 *然后再执行查询,计算总行数和总的页数 ********************************************************/ String query = "select * 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()) { %> <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">商品详细信息</a> </td> </tr> <% resultset.next(); i=i+1; } } %>
这里是大概的代码,请看什么地方有错误, <%=resultset.getString("lsdj")%>
这句去掉就可以,不去掉就不行
|