📄 jobnews.jsp
字号:
<%@ include file="conn.jsp"%>
<%
int intPageSize;
int intRowCount;//记录总数
int intPageCount;//总页数
int intPage;//页面参数
String strPage;//定义变量用来传递page
int i,j;
intPageSize=5;//定义每页显示5条记录
strPage=request.getParameter("page");//取得当前的页码
if(strPage==null){//判断初始页面,如果没有显示记录,就置为第一页
intPage=1;
}else{
intPage=Integer.parseInt(strPage);//将strPage转化为整数
if(intPage<1) intPage=1;
}
//ResultSet rt = stmt.executeQuery("select count(*) lcount from scott.learning");//取得记录总数
//String sql="select count(*) from scott.learning";
String sqlname;
sqlname="select count(id) from scott.jobnews order by id desc" ;
ResultSet rt=stmt.executeQuery(sqlname);
rt.next();
intRowCount=rt.getInt(1);//取得整数保存与intRowCount变量中
intPageCount=(intRowCount+intPageSize-1)/intPageSize;//计算出总页数(记录总数+每页显示的记录-1)/每页显示的记录)
if(intPage>intPageCount)
intPage=intPageCount;
sqlname="select * from scott.jobnews order by id desc" ;
ResultSet rs=stmt.executeQuery(sqlname);//执行sql,按照时间先后排序显示
i=(intPage-1)*intPageSize;
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="inc/index.css" type="text/css">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>新闻资讯|NEWS</title>
</head>
<body>
<div align="center">
<table border="1" cellpadding="0" cellspacing="0" width="430" bordercolor="#000000" bordercolorlight="#000000" bordercolordark="#FFFFFF">
<tr>
<td width="270" height="17" valign="bottom" background="images/t-bg1.gif">
<p align="left"> 新闻资讯|NEWS</td>
<td width="154" height="17" valign="bottom" background="images/t-bg1.gif">
<p align="center">共<font color="#0000AE"><%=intRowCount%></font>条新闻 页次:<font color="#0000AE"><%=intPage%></font>/<%=intPageCount%></td>
</tr>
<center>
<tr bgcolor="#fffff4">
<td width="448" valign="bottom" colspan="2">
<%
i=0;
while(i<intPageSize && rs.next()){
%>
==> <a href="viewnews.jsp?id=<%=rs.getString("id")%>" target="_blank">
<%=rs.getString("title")%>
</a><I> [<%=rs.getString("idate")%>]</I> 点击<font color="#000091"><%=rs.getString("click")%></font>次<BR>
<% i++;//通过I循环设置每页的页数
} %>
</td>
</tr>
</center>
<tr>
<td width="448" height="17" valign="bottom" background="images/t-bg1.gif" colspan="2">
<p align="center">
<% for(j=0;j<i;j++)
%>
<%-- 设置intPage参数 --%>
<FORM action=index.jsp method=POST>
<p align='center' vAlign='bottom'>
第<%=intPage%>页 共<%=intPageCount%>页
<%if(intPage<intPageCount){%>
<a href="jobnews.jsp?page=<%=intPage+1%>">下一页</a>
<%}%>
<%if(intPage>1){%>
<a href="jobnews.jsp?page=<%=intPage-1%>">上一页</a>
<%}%>
</form>
</td>
</tr>
</form>
</td>
</tr>
</table>
</div>
<p align="center">【<a href="javascript:window.close()">关闭窗口</a>】</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -