📄 index.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" %>
<jsp:useBean id="DBConnection" scope="page" class="com.guestbook.DBConnection"/>
<%
Boolean a=(Boolean)session.getAttribute("a");
Connection conn=DBConnection.getConnectionToAccess(application.getRealPath("data/guestbook.mdb"));
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>SunShine留言本v1.0</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
<SCRIPT language=JavaScript>
<!--
function go(src,q)
{
var ret;
ret = confirm(q);
if(ret!=false)window.location=src;
}
function openwin(url, width, height)
{
var Win = window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=1,menubar=0,status=1');
}
function openreply()
{
document.viewreply.replycodes.value=document.replyform.replycode.value;
var popupWin = window.open('Viewreply.asp', 'viewreply_page', 'scrollbars=yes,width=700,height=450');
document.viewreply.submit()
}
-->
</script>
</head>
<body leftmargin="0" topmargin="0">
<jsp:include page="top.htm" />
<table cellspacing=0 cellpadding=0 width=760 align=center border=0 bgcolor="#FFFFFF">
<tbody>
<tr>
<td width="200" valign=top>
<jsp:include page="left.jsp" />
</td>
<td valign=top class="tdbg_leftall">
<table cellspacing=0 cellpadding=0 border=0>
<tbody>
<tr>
<td valign=top>
<table cellspacing=0 cellpadding=0 width="100%" align=center border=0>
<tbody>
<tr>
<td></td>
</tr>
<tr>
<td valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="560"> <table border="1" width="99%" cellspacing="0" cellpadding="0" align="center" bgcolor="#336699" bordercolordark="#FFFFFF" bordercolorlight="#666666">
<tr>
<%
String sql="select * from Guestbook order by id DESC";
ResultSet Rs=stmt.executeQuery(sql);
int intPageSize; //一页显示的记录数
int intRowCount; //记录总数
int intPageCount; //总页数
int intPage; //待显示页码
String strPage;
int i;
//设置一页显示的记录数
intPageSize = 6;
//取得待显示页码
strPage = request.getParameter("page");
if(strPage==null){//表明在QueryString中没有page这一个参数,此时显示第一页数据
intPage = 1;
} else{//将字符串转换成整型
intPage = java.lang.Integer.parseInt(strPage);
if(intPage< 1) intPage = 1;
}
//获取记录总数
Rs.last();
intRowCount = Rs.getRow();
//记算总页数
intPageCount = (intRowCount+intPageSize-1) / intPageSize;
//调整待显示的页码
if(intPage >intPageCount) intPage = intPageCount;
if(intPageCount >0){
//将记录指针定位到待显示页的第一条记录上
Rs.absolute((intPage-1) * intPageSize+1);
//显示数据
%>
<td width="75%" height="28"> <strong><font color="#DEEBF5">SunShine留言列表:</font></strong></td>
<td width="25%" align="center"> <font color="#DEEBF5"> <strong>共
<%=intRowCount%> 条留言</strong></font></td>
</tr>
</table>
<%
i = 0;
while(i< intPageSize && !Rs.isAfterLast()){
//读留言信息
int id=Rs.getInt("id");
String username=Rs.getString("username");
String userface=Rs.getString("userface");
String userurl=Rs.getString("userurl");
String usermail=Rs.getString("usermail");
String userqq=Rs.getString("userqq");
String usertitle=Rs.getString("usertitle");
String content=Rs.getString("content");
String mydate=Rs.getString("mydate");
String remydate=Rs.getString("remydate");
String recontent=Rs.getString("recontent");
String ip=Rs.getString("ip");
%>
<table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="28"><table border="1" width="100%" cellspacing="0" cellpadding="0" align="center" bgcolor="#4791C5" bordercolordark="#FFFFFF" bordercolorlight="#666666">
<tr>
<form name="form1" method="post" action="default.asp">
<td width="75%" height="24"> <strong><font color="#FFFFFF">欢迎您使用SunShine留言本。</font></strong></td>
<td width="25%" align="center"> <font color="#FFFF00"> </font>
<font color="#FFFFFF">第<%=id%>位留言者</font></td>
</form>
</tr>
</table></td>
</tr>
</table>
<table width="99%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolorlight="#666666" bordercolordark="#FFFFFF" style="word-break:break-all;font-family: Arial, Helvetica, sans-serif;">
<tr>
<td width="140" align="center" valign="top" bgcolor="#F5F5F5" ><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height=20></td>
</tr>
</table>
<img src="images/<%=userface%>.gif" width="72" height="72"><br>
<br>
<%=username%> </td>
<td valign="top"> <table width="100%" border="0" align="center" cellpadding="1" cellspacing="3">
<tr>
<td bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#999999">
<tr>
<td bgcolor="#FFFFFF"><table width="100%" height="24" border="0" cellpadding="0" cellspacing="0" bgcolor="#f5f5f5">
<tr>
<td width="50%"> 标题:<%=usertitle%> </td>
<td width="50%"> <div align="right">
<a href="<%=userurl%>" target="_blank"><img src="images/home.gif" width="16" height="16" border="0" align="absmiddle" alt="主页:[ <%=userurl%> ]"></a>
|
<a href="mailto:<%=usermail%>" target="_blank"><img src="images/email.gif" width="18" height="18" border="0" align="absmiddle" alt="电子邮件:[ <%=usermail%> ]"></a>
|
<a href="#"><img src="images/qq-gray.gif" width="16" height="16" border="0" align="absmiddle" alt="QQ号码:<%=userqq%>"></a>
|
<a href="#"><img src="images/ip.gif" width="16" height="16" border="0" align="absmiddle" alt="来自:[ <%=ip%> ]"></a>
</div></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<table width="100%" height="100%" border="0" cellpadding="1" cellspacing="5">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><fieldset style="width:100%;" align="center;">
<legend> <strong>留言内容: </strong></legend>
<table width="100%" border="0" cellspacing="4" cellpadding="0">
<tr>
<td height="60">
<%=content%></td>
</tr>
</table>
</fieldset></td>
</tr>
</table>
<div align="right">发表时间:
<%=mydate%>
</div></td>
</tr>
</table></td>
</tr>
<%
if(recontent!=null)
{
//站长回复
%>
<tr>
<td height="30" align="center" bgcolor="#f0f0f0" ><FONT color=red>站长回复:</font></td>
<td bgcolor="f5f5f5">
<table width="100%" border="0" cellspacing="4" cellpadding="0">
<tr>
<td>
<FONT color=red><%=recontent%></FONT></td>
</tr>
</table></td>
</tr>
<%
}
if(a==null||a.booleanValue()==false)
{}else{
%>
<tr>
<td colspan="2" bgcolor="#FFFFFF"><div align="right"><a href="javascript:go('del.jsp?id=<%=id%>','您确定要删除?')">删除</a>
<a href="JavaScript:openwin('Reply.jsp?id=<%=id%>',600,500)">回复/编辑回复</a>
<a href="JavaScript:openwin('Edit.jsp?id=<%=id%>',600,500)">编辑</a>
</font></div></td>
</tr>
<%
}
%>
</table>
<br>
<%
Rs.next();
i++;
//读流言信息结束
}
%>
<table border="1" width="99%" cellspacing="0" cellpadding="0" align="center" bgcolor="#F5F5F5" bordercolordark="#FFFFFF" bordercolorlight="#666666">
<tr>
<td height="24" align="center"><div align="right">第<%=intPage%>页 共<%=intRowCount%>条记录/共<%=intPageCount%>页
<%
if(intPage<2){
out.print("首页 | 上一页");
}else{%>
<a href="index.jsp?page=1">首页 </a> | <a href="index.jsp?page=<%=intPage-1%>">上一页</a>
<%}%>|
<%
if((intPageCount-intPage)<1)
{
out.print("下一页 | 尾页");
}else{%>
<a href="index.jsp?page=<%=intPage+1%>">下一页</a> | <a href="index.jsp?page=<%=intPageCount%>">尾页</a>
<%}
}
else{
}
if(conn!=null)
{
conn.close();
}
if(stmt!=null)
{
stmt.close();
}
%>
</div>
</td>
</form>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<jsp:include page="bottom.htm" />
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -