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

📄 lingdao.jsp

📁 JSP+ORACLE网站开发实例(下).rar
💻 JSP
字号:
<%@ include file="conn.jsp"%>
<html>
<head>
<title>新闻网</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="images/css.css" rel=stylesheet type=text/css>
<style type="text/css">
<!--
body {
	background-image: url(images/pagebg1.gif);
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
</head>

<body>
<table width="780" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#CACACA">
  <tr>
    <td bgcolor="#FFFFFF"><%@ include file="top.inc"%>
    <table width="780" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="171" valign="top" bgcolor="F7EEE4"><%@ include file="left.inc"%></td>
          <td width="609" valign="top"><table width="580" border="0" align="center" cellpadding="5" cellspacing="5">
            <tr>
              <td width="590" colspan="2"><img src="images/deng7.gif" width="580" height="60"></td>
            </tr>
          </table>   
            <b>&nbsp;&nbsp;&nbsp; </b>
<table width="560"  border="0" align="center" cellpadding="3" cellspacing="3" class="txt1" id="table1">
            <tr><%  sql="select articleid,title,picurl from scott.article where classid=7 order by addtime desc"; 
  rst=stmt.executeQuery(sql); 
  ii=1;
 while(rst.next()) {
           %>                   
              <td>
				<table width="98%"  border="0" cellspacing="4" cellpadding="4" id="table2">
                  <tr>
                    <td align="center" class="txt1"><a href="renwu2.jsp?id=<%=rst.getString("articleid")%>"><img src="<%=rst.getString("picurl")%>" width="80" height="101" border="0"></a> </td>
                  </tr>
                  <tr>
                    <td align="center"><a href="renwu2.jsp?id=<%=rst.getString("articleid")%>" class="list5"><%=rst.getString("title")%></a></td>
                  </tr>
              </table></td>
              <% if(ii%4==0){%>
			  </tr><tr>
			  <%}
			  ii++;
			  }%>
              
            </table> 
            &nbsp;&nbsp;&nbsp;&nbsp; 
            <table width="570"  border="0" align="center" cellpadding="4" cellspacing="4" id="table1">
              <tr> 
                <td class="txt5"> 相关文章: </td>
              </tr>
            </table>
            <table width="560"  border="0" align="center" cellpadding="3" cellspacing="3" class="txt1">

       <%String sqlname;
int intPageSize;
int intRowCount;//记录总数
int intPageCount;//总页数
int intPage;//页面参数
String strPage;//定义变量用来传递page
int i,j;
intPageSize=10;//定义每页显示10条记录
strPage=request.getParameter("page");//取得当前的页码
if(strPage==null){//判断初始页面,如果没有显示记录,就置为第一页
intPage=1;
}else{
intPage=Integer.parseInt(strPage);//将strPage转化为整数
if(intPage<1) intPage=1;
}



 sqlname="select count(articleid) from scott.article where classid=19 order by addtime desc";


rst=stmt.executeQuery(sqlname); 


rst.next();
intRowCount=rst.getInt(1);//取得整数保存与intRowCount变量中
intPageCount=(intRowCount+intPageSize-1)/intPageSize;//计算出总页数(记录总数+每页显示的记录-1)/每页显示的记录)
if(intPage>intPageCount)
intPage=intPageCount;


 sqlname="select articleid,title,addtime from scott.article where classid=19 order by addtime desc";


 rst=stmt.executeQuery(sqlname);//执行sql,按照时间先后排序显示
i=(intPage-1)*intPageSize;
for(j=0;j<i;j++)
rst.next();
%>
<%-- 设置intPage参数 --%>
  <%if(intRowCount==0){%>
		  对不起,还没有数据!
		  <%}else{%>
		<%-- 显示每页的数据 (根据i的值判断每页的20条记录) --%>
            <%
		i=0;
		while(i<intPageSize && rst.next()){
%>
              <tr>
                <td width="4%"><img src="images/iocn1.gif" width="7" height="7"></td>
                <td width="77%" class="txt1"><a href="show.jsp?id=<%=rst.getString("articleid")%>" target="_blank" class=list3><%=rst.getString("title")%></a> 
                 </td>
                <td width="19%" class="txt3">[<%=rst.getDate("addtime")%>]</td>
              </tr>
                  <%	  i++;//通过I循环设置每页的页数
		}


%>
	<%}

  rst.close(); %>
<tr><td> </td>
                               <td align="center"></td>	  <div align="center">                           
<p align='center' vAlign='bottom' >
				第<%=intPage%>页 &nbsp;&nbsp;&nbsp;共<%=intPageCount%>页&nbsp;&nbsp;&nbsp;
				<%if(intPage<intPageCount){%>
				<a href="lingdao.jsp?page=<%=intPage+1%>" class="list3">下一页</a>&nbsp;&nbsp;&nbsp;
				<%}%>
				<%if(intPage>1){%>
				<a href="lingdao.jsp?page=<%=intPage-1%>" class="list3">上一页</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<%}%>
				 </div>   <td class="txt3"> </td> </tr>
            </table>
          </td>
        </tr>
      </table>
			<%@ include file="end.inc"%></td>
        </tr>
      </table>
</body>
</html>

⌨️ 快捷键说明

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