⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 list.jsp

📁 JSP入门与提高.大量丰富的实例。
💻 JSP
字号:
<html>
<head>
<%@ page contentType="text/html;charset=gb2312" %> 
<title>bid-right</title>
<link rel=stylesheet href="../style.css" type="text/css">
<script LANGUAGE="javascript">
function newwin(url) {
  var newwin=window.open(url,"newwin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=400,height=350");
  newwin.focus();
  return false;
}
</script>
</head>
<body leftmargin="20" topmargin="20">
<script LANGUAGE="javascript">
function submit11()
{
self.location.replace("index.jsp")
}
</script>
<div align="center"><h4><font color="blue">库存拍卖</font></h4></div></p>
<%@ page language="java" import="java.sql.*" %>
<jsp:useBean id="bidBean" scope="page" class="firm.firm" />
<%
//指定行数
int pageLine=10;
int totalRec=0;
int totalSub=0;
int intPage=1;
int i;
String item1=request.getParameter("type");
session.putValue("pid",item1);
//把type_id转换成整型
int item=Integer.parseInt(item1);
if (request.getParameter("page")!=null)
intPage=Integer.parseInt(request.getParameter("page"));

try{
ResultSet countrs=null;

//取得总记录数
String sqlstr="select count(*) as cnt from product where type_id="+ item +"";
countrs=bidBean.executeQuery(sqlstr);
if (countrs.next())
 totalRec=countrs.getInt("cnt");
 countrs.close();
 bidBean.closeStmt();

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

//取得总页数
int intPageCount=0;
intPageCount = (totalRec+pageLine-1) / pageLine;
%>
<%
ResultSet RS = bidBean.executeQuery("SELECT * FROM product where type_id="+ item +" order by product_id desc");
String serial;
String title;
String qixian;
String sprice;
int bid;
%>
<table border='1' cellspacing='0' width='580' bgcolor='#d7e3b9' bordercolorlight='#4DA6FF' bordercolordark='#ECF5FF'>
<tr bgcolor='#c8cc98' align='center'> 
      <td width="60" >商品ID号</td>
      <td width="140" >商品名称</td>
      <td width="80" >起始价格</td>
      <td width="60" >拍卖期限</td>
      <td width="40" >竞标数</td>
      
</tr>
<%
if (intPageCount>0)
{
           for(i=1;i<=(intPage-1)*pageLine;i++)
			RS.next();
	   for(i=1;i<=pageLine;i++) {
			if (RS.next()) {

                           serial=RS.getString("product_id");
                           title=RS.getString("title");
                           qixian=RS.getString("period");
                           sprice=RS.getString("sprice");
                           bid=RS.getInt("bids");
                        
%>

<tr>
   <td width='60' align='center'><%=serial%></td>
   <td width='140'><a href="view.jsp?mid=<%=serial%>"><%=title%></a></td>
   <td width='80' align='center'><%=sprice%></td>
   <td width='60'align='center'><%=qixian%></td>
   <td width='40'align='center'><%=bid%></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='list.jsp'>");
		out.print("<p align='left'>&gt;&gt;分页&nbsp;");
		out.print("<a href='product/search.jsp' onClick='return newwin(this.href);'>商品查询</a>&nbsp;");
  	        
  	if (intPage<2)
    		out.print("<font color='999966'>首页 上一页</font>&nbsp;");
  	else{   
  		out.print("<a href='list.jsp?page=1'>首页</a>&nbsp;");   
    		out.print("<a href='list.jsp?page=" + (intPage-1) + "'>上一页</a>&nbsp;"   );
    	}
  	
  	  
  	if( intPage-intPageCount>=0 )
    		out.print("<font color='999966'>下一页 尾页</font>"   );
  	else{   
  		
    		out.print("<a href='list.jsp?page=" + (intPage+1)+ "'>下一页</a> <a href='list.jsp?page=" + intPageCount + "'>尾页</a>");
    	}
 
        out.print("&nbsp;页次:<strong><font color=red>"+intPage+"</font>/"+intPageCount+"</strong>页 "   );
   	out.print("&nbsp;共<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='确定'  name='cndok'></span></p></form>"  ); 

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

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -