jsp怎么获取某一单元格的值,这该如何修改,把某一行的值传递给下一页面,而不是数据库所有内容都传入
字数原因顶部没用:<palign="center">商品展示</p><tablewidth="100%"height="45"border="1"cellpadding=...
字数原因顶部没用:
<p align="center">商品展示</p>
<table width="100%" height="45" border="1" cellpadding="0" cellspacing="0" >
<tr>
<td width="18%">商品名称</td>
<td width="19%">价格</td>
<td width="20%">数量</td>
<td width="20%">购买</td>
</tr>
<%
int pageSize=3;//每页显示的条数
int rowCount=0;//总条数
int pageCount=0; //总页数
int pageNow=1;//当前显示的第几页
String spageNow=request.getParameter("pageNow");
if(spageNow!=null){
pageNow=Integer.parseInt(spageNow);
}
String driverClass="org.gjt.mm.mysql.Driver";
String url="jdbc:mysql://localhost:3306/user";
String user="root";
String password4="root";
Connection conn;
Statement stmt;
ResultSet rs;
try{
Class.forName(driverClass);
conn =DriverManager.getConnection(url,user,password4);
stmt=conn.createStatement();
rs=stmt.executeQuery("select count(*) from goods ");
if(rs.next())
{
rowCount=rs.getInt(1);
}
rs=stmt.executeQuery("select * from goods order by goodsname limit "+(pageNow-1)*pageSize+","+pageSize+"");
///()第二个参数是每页显示几条
while(rs.next()){
%>
<tr>
<td width="18%" align="left"><font size="2"><%=rs.getString(1) %></font></td>
<td width="19%" align="left"><font size="2"><%=rs.getInt(2) %></font></td>
<td width="31%" align="left"><font size="2"><%=rs.getInt(3) %></font></td>
<td><a href="buy.jsp?goodname=${goods.name}" class="STYLE9">购买</a></td>
</tr>
<%
}
if(rs!=null){rs.close();}
if(stmt!=null){stmt.close();}
if(conn!=null){conn.close();}
}
catch (Exception e)
{
e.printStackTrace();
}
%>
</table>
<center>
<%
if((rowCount%pageSize)==0){
pageCount=rowCount/pageSize;
}else{
pageCount=rowCount/pageSize+1;
}
if(pageNow!=1)
{
%>
<a href="show.jsp?pageNow=<%= pageNow-1%>"> 上一页</a>
<%
}/////这个括号很重要噢!!
for(int i=pageNow;i<=pageNow+3;i++){
if(i<=pageCount){
%>
<a href="show.jsp?pageNow=<%=i %>"> <%=i%> </a>
<%
}
}
if(pageNow!=pageCount)
{
%>
<a href="show.jsp?pageNow=<%= pageNow+1%>"> 下一页</a>
<%
}
%>
</center>
<p align="center"><td><a href="addgoods.jsp">添加商品</a></td></p>
</body>
</html> 展开
<p align="center">商品展示</p>
<table width="100%" height="45" border="1" cellpadding="0" cellspacing="0" >
<tr>
<td width="18%">商品名称</td>
<td width="19%">价格</td>
<td width="20%">数量</td>
<td width="20%">购买</td>
</tr>
<%
int pageSize=3;//每页显示的条数
int rowCount=0;//总条数
int pageCount=0; //总页数
int pageNow=1;//当前显示的第几页
String spageNow=request.getParameter("pageNow");
if(spageNow!=null){
pageNow=Integer.parseInt(spageNow);
}
String driverClass="org.gjt.mm.mysql.Driver";
String url="jdbc:mysql://localhost:3306/user";
String user="root";
String password4="root";
Connection conn;
Statement stmt;
ResultSet rs;
try{
Class.forName(driverClass);
conn =DriverManager.getConnection(url,user,password4);
stmt=conn.createStatement();
rs=stmt.executeQuery("select count(*) from goods ");
if(rs.next())
{
rowCount=rs.getInt(1);
}
rs=stmt.executeQuery("select * from goods order by goodsname limit "+(pageNow-1)*pageSize+","+pageSize+"");
///()第二个参数是每页显示几条
while(rs.next()){
%>
<tr>
<td width="18%" align="left"><font size="2"><%=rs.getString(1) %></font></td>
<td width="19%" align="left"><font size="2"><%=rs.getInt(2) %></font></td>
<td width="31%" align="left"><font size="2"><%=rs.getInt(3) %></font></td>
<td><a href="buy.jsp?goodname=${goods.name}" class="STYLE9">购买</a></td>
</tr>
<%
}
if(rs!=null){rs.close();}
if(stmt!=null){stmt.close();}
if(conn!=null){conn.close();}
}
catch (Exception e)
{
e.printStackTrace();
}
%>
</table>
<center>
<%
if((rowCount%pageSize)==0){
pageCount=rowCount/pageSize;
}else{
pageCount=rowCount/pageSize+1;
}
if(pageNow!=1)
{
%>
<a href="show.jsp?pageNow=<%= pageNow-1%>"> 上一页</a>
<%
}/////这个括号很重要噢!!
for(int i=pageNow;i<=pageNow+3;i++){
if(i<=pageCount){
%>
<a href="show.jsp?pageNow=<%=i %>"> <%=i%> </a>
<%
}
}
if(pageNow!=pageCount)
{
%>
<a href="show.jsp?pageNow=<%= pageNow+1%>"> 下一页</a>
<%
}
%>
</center>
<p align="center"><td><a href="addgoods.jsp">添加商品</a></td></p>
</body>
</html> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询