我的整个程序是这样的,我估计这句不太对(<th scope="row"><div align="center"><a target="product" href="wares_detail.jsp?productid=<%=list.WaresId%>"><img src="D:\Tomcat\Tomcat 5.0\webapps\ROOT\jing\picture\jsp\<%=list.SmallImg%>"></a></div></th>
),不知道怎么改:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="com.*" %>
<jsp:useBean id="pagebean" scope="session" class="com.pagebean"/>
<jsp:useBean id="databean" scope="session" class="com.conndb"/>
<jsp:useBean id="list" scope="session" class="com.WaresList"/>
<HTML>
<title>商品浏览</title>
<body topmargin="45" background="D:\Tomcat\Tomcat 5.0\webapps\ROOT\jing\picture\back.bmp">
<h1><center>欢迎光临商品浏览页面!</center></h1>
<hr>
<%
ResultSet rs;
String sql="SELECT * FROM wares"; //查询表wares中的所有数据
rs=databean.executeQuery(sql); //执行sql语句,使用了javabean conndb中的executeQuery
String pages=request.getParameter("dipage"); //读取当前的页数
rs.last();
int countRecord=rs.getRow(); //得到记录的条数
int countPageRecord=5; //设置每页记录条数
if(pages==null||(pages.trim()).length()==0) //如果当前页数不存在,也就是初次进入页面
pagebean.setAll(countRecord,countPageRecord); //参数初始化,使用javabean pagebean中的setall,当前页数设为1
else
{
try
{
pagebean.setCurrentPage(Integer.parseInt(pages));
}
catch(Exception e)
{
out.println("参数不正确!");
}
}
//当前记录号
int currentRecord=(pagebean.getCurrentPage()-1)*pagebean.getSizePage();
if(currentRecord==0)
rs.beforeFirst();
else
rs.absolute(currentRecord);
//显示当前页数据
%>
<br>
<br>
<br>
<center>
<%
out.print("<Table Border style='font-size: 10pt'>");
out.print("<TR><td colspan=8 align=center><h1><font color=green>商品列表</font></h1></td></tr>");
out.print("<TR>");
out.print("<Td width=100 >"+"商品自动编号");
out.print("<Td width=100 >"+"商品所属种类");
out.print("<Td width=100>"+"商品名称");
out.print("<Td width=100>"+"商品市场价");
out.print("<Td width=100>"+"商品现价");
out.print("<Td width=100>"+"商品缩略图");
out.print("<Td width=100>"+"商品图片途径");
out.print("<Td width=100>"+"商品说明");
out.print("</TR>");
%>
<%
int i=0;
while(rs.next())
{ out.print("<TR>");
out.print("<TD >"+rs.getLong(1)+"</TD>");
out.print("<TD >"+rs.getString("Sort")+"</TD>");
out.print("<TD >"+rs.getString("Name")+"</TD>");
out.print("<TD >"+rs.getInt("MarketPrice")+"</TD>");
out.print("<TD >"+rs.getString("Price")+"</TD>");
%>
<th scope="row"><div align="center"><a target="product" href="wares_detail.jsp?productid=<%=list.WaresId%>"><img src="D:\Tomcat\Tomcat 5.0\webapps\ROOT\jing\picture\jsp\<%=list.SmallImg%>"></a></div></th>
<%
out.print("<TD >"+rs.getString("BigImg")+"</TD>");
out.print("<TD >"+rs.getString("Description")+"</TD>");
%>
<th scope="row"><input name="check" type="checkbox" id="check" value="<%=list.WaresId%>">
<%
out.print("</TR>") ;
i++;
if(i>=pagebean.getSizePage()) break; //当前页显示完,则退出循环
}
out.print("<TR><td colspan=8 align=center>");
out.print("共"+pagebean.getCountRecord()+"条记录,共"+pagebean.getCountPage()+"页,当前第"+pagebean.getCurrentPage()+"页,每页"+pagebean.getSizePage()+"条记录,");
if(pagebean.getCurrentPage()==1)//当前是首页
;
else//当前不是首页
{
out.print("<a href=wares_list.jsp?dipage=1>首页</a>,");
out.print("<a href=wares_list.jsp?dipage="+(pagebean.getCurrentPage()-1)+">上一页</a>,");
}
if(pagebean.getCurrentPage()==pagebean.getCountPage())//当前是末页
;
else//当前不是末页
{
out.print("<a href=wares_list.jsp?dipage="+(pagebean.getCurrentPage()+1)+">下一页</a>,");
out.print("<a href=wares_list.jsp?dipage="+pagebean.getCountPage()+">末页</a>");
}
out.print("</td></tr>");
out.print("</Table>");
databean.freeRs(rs); //释放rs
%>
</center>
</body>
</HTML>