📄 zhongshuofenyun.jsp
字号:
<%@ page contentType="text/html;charset=gb2312" import="java.sql.*,java.io.*" errorPage="" %>
<%@ include file="yeshou.txt" %>
<html>
<meta http-equiv="refresh" content="50"; charset=gb2312" />
<head>
<title>众说纷纭</title>
<script language="javascript">
window.onunload = function(){
window.opener.location.reload();
}
</script>
<% String windows="window.open('load1.jsp','','height=200, width=200, top=0, lef t=0, toolbar=no, menubar=no, scrollbars=no,resizable=no,location=no, statu s=no')";%>
</head>
<body bgcolor="#99CCCC">
<table width="780" bordercolor="#66a88" border="0" align="center" bordercolor"#669999">
<br>
<span style="font-size: 18px"><a href="wenzhangfabu.jsp">发表文章</a><img src="picture/lyb_write.gif" width="20" height="20"></span></a>
<%if(session.getAttribute("flag1")!="2"){%>
<a href="#" onClick="<%=windows%>" style="font-size: 18px"> 文章管理<img src="picture/lyb_admin.gif" width="20" height="20"></a>
<%}else if(session.getAttribute("flag1")=="2"){ %>
<a href="guanli.jsp" style="font-size: 18px"> 文章管理<img src="picture/lyb_admin.gif" width="20" height="20"></a>
<%}%>
<tr></tr>
<%String s=(String)session.getAttribute("customer");
int intPageSize; //一页显示的记录数
int intRowCount; //记录总数
int intPageCount; //总页数
int intPage; //待显示页码
String strPage;
int i;
intPageSize = 10;//设置一页显示的记录数
strPage = request.getParameter("page");//取得待显示页码
if(strPage==null){//表明在QueryString中没有page这一个参数,此时显示第一页数据
intPage = 1;
}
else{//将字符串转换成整型
intPage = Integer.parseInt(strPage);
if(intPage<1) intPage = 1;
}
//装载JDBC驱动程序
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:test","sa","sa");
//设置数据库连接字符串
//连接数据库
Statement st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
//创建一个可以滚动的只读的SQL语句对象
//准备SQL语句
String sql = "select * from wenzhang order by id desc";
//执行SQL语句并获取结果集
ResultSet rs=st.executeQuery(sql);
rs.last();
intRowCount = rs.getRow();
//记算总页数
intPageCount = (intRowCount+intPageSize-1) / intPageSize;
//调整待显示的页码
if(intPage>intPageCount)
intPage = intPageCount;
if(intPageCount>0){
//将记录指针定位到待显示页的第一条记录上
rs.absolute((intPage-1) * intPageSize + 1);
//显示数据
i = 0;
while(i<intPageSize &&!rs.isAfterLast()){%>
<%if(session.getAttribute("flag1")!="2"&&session.getAttribute("flag")!="1"){%>
<tr><td bgcolor="#66a88">文章标题: <a href="wenzhangxianshi.jsp?id=<%=rs.getString(1)%>" style="font-size: 20px"><%=rs.getString(2)%></a><br>
<%
String str=rs.getString(3);
String str1=rs.getString(5);
out.print("发表用户:"+str+"<br>");
out.print("发表日期:"+str1+"</td></tr>");
}else
if(session.getAttribute("flag1")=="2"){
String id=rs.getString(1);%>
<tr><td bgcolor="#66a88">文章标题:<a href="wenzhangxianshi.jsp?id=<%=id%>" style="font-size: 20px"><%=rs.getString(2)%></a><br>
<%
String str=rs.getString(3);
String str1=rs.getString(5);
out.print("发表用户:"+str+"<br>");
out.print("发表日期:"+str1);%>
<a href="delete.jsp?id2=<%=id%>">删除该文章<img src="picture/c.gif" width="20" height="20"></a></td></tr>
<%}else if(session.getAttribute("flag")=="1"){
String id=rs.getString(1);%>
<tr><td bgcolor="#66a88">文章标题:<a href="wenzhangxianshi.jsp?id=<%=id%>"><%=rs.getString(2)%></a><br>
<%
String str=rs.getString(3).trim();
String str1=rs.getString(5);
out.print("发表用户:"+str+"<br>");
out.print("发表日期:"+str1);
if(s.equals(str)){
%>
<a href="wenzhangedit.jsp?id1=<%=id%>">编辑文章<img src="picture/lyb_write.gif" width="20" height="20"></a>
<a href="delete.jsp?id2=<%=id%>">删除文章<img src="picture/c.gif" width="20" height="20"></a></td></tr>
<%}}rs.next();
i++;
}
}
con.close();
//关闭SQL语句对象
%>
</table>
<table width="780" align="center">
<FORM METHOD=POST ACTION="zhongshuofenyun.jsp">
<div align="left" align="left" >
<td align="center" width="780">
<div align="left">
<INPUT TYPE="text" size="4" value=<%= intPage%> NAME="page">
<INPUT TYPE="submit" size=4 value="GO!">
第<%=intPage%>页 共<%=intPageCount%>页
<a href="zhongshuofenyun.jsp?page=1">首页</a>
<%if(intPage>1){%>
<a href="zhongshuofenyun.jsp?page=<%=intPage-1%>">上一页</a>
<%}%>
<%if(intPage<intPageCount){%>
<a href="zhongshuofenyun.jsp?page=<%=intPage+1%>">下一页</a>
<%}%>
<a href="zhongshuofenyun.jsp?page=<%=intPageCount%>">末页</a>
</div>
</FORM>
</td>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -