📄 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>时空留言本v2.0-显示留言</title>
<style type="text/css">
<!--
body {
border: 1px 1 #CCCCCC;
}
.bian {
border-top-width: 1px;
border-top-style: solid;
border-top-color: #969696;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #999999;
}
.f12 {
font-family: "宋体";
font-size: 12px;
color: #000000;
text-decoration: none;
line-height: 23px;
height: auto;
}
.bian1 {
border-right-width: 1px;
border-left-width: 1px;
border-right-style: solid;
border-left-style: solid;
border-right-color: #969696;
border-left-color: #969696;
}
a:link {
font-family: "宋体";
font-size: 12px;
color: #333333;
text-decoration: none;
}
a:visited {
font-family: "宋体";
font-size: 12px;
color: #333333;
text-decoration: none;
}
a:hover {
font-family: "宋体";
font-size: 12px;
color: #333333;
text-decoration: underline;
}
a:active {
font-family: "宋体";
font-size: 12px;
color: #333333;
text-decoration: none;
}
input {
font-size: 12px;
}
button {
margin: 1px;
padding: 1px;
border: 1px solid #CCCCCC;
background-color: #CCCCCC;
}
-->
</style>
<script language="javascript">
function checks(){
if(post1.password.value==""){
alert("请输入管理员密码");
return false;
}
if(post1.password.value.length>20){
alert("管理员密码不超过20位");
return false;
}
return true;
}
</script>
<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" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="20%"><img src="images/images/logo.gif" width="150" height="45"></td>
<td width="80%" style="FILTER: progid:DXImageTransform.Microsoft.Gradient(startColorStr='#FFFFFF', endColorStr='#5581D2', gradientType='1'; BORDER-BOTTOM: #969696 1px solid"> </td>
</tr>
</table>
<table width="100%" border="0" cellpadding="3" cellspacing="3" class="bian">
<form action="loginpost.jsp" method="post" name="post1" id="post1" onsubmit="return checks();">
<tr>
<td>
<%
//读管理员信息
String sql1="select * from admin where id=1";
ResultSet Rs1=stmt.executeQuery(sql1);
while(Rs1.next())
{
%>
<span class="f12">┃<font color="#333333"><a href="<%=Rs1.getString("url")%>" target="_blank">欢迎光临<strong><font face="Arial, Helvetica, sans-serif"> <%=Rs1.getString("site")%></font></strong></a>┃你的IP是<strong><font face="Arial, Helvetica, sans-serif"><%= request.getRemoteAddr() %></font></strong>┃
<%
if(a==null||a.booleanValue()==false)
{
%>
管理员:<strong><a href="mailto:<%=Rs1.getString("email")%>"><font face="Arial, Helvetica, sans-serif"><%=Rs1.getString("admin")%></font></a></strong>
密码 :</font> </span><font color="#333333">
<input name='password' type="password" class="f12" id="adminpass" size="8">
<span class="f12">
<input name="submit2" type="submit" value="管理登陆">
</span></font><span class="f12"><font color="#333333">
<%}else{%>
</font> ┃<font color="#333333"><a href="index.jsp">管理留言</a></font>┃<font color="#333333"><a href="admin.jsp">设置留言本</a></font>┃<a href="logout.jsp">退出登陆</a>┃ </span>
<%}
//结束读管理员信息
}%>
</td>
</tr>
</form>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="bian1">
<tr>
<td style="border-right: 1px solid #969696" vAlign=top width=100
bgColor=#f1f1f1 height="396" >
<TABLE width="100%" height="135" border=0 cellPadding=5 cellSpacing=0
borderColor=#111111 class="f12" id=AutoNumber1 style="BORDER-COLLAPSE: collapse">
<TBODY>
<TR>
<TD width="100%" height="46" align=right bgColor=#f1f1f1> </TD>
</TR>
<TR>
<TD id=menu1 align=right width="100%" bgColor=#5581d2 height=15><B><a href="index.jsp">查看留言</a></B></TD>
</TR>
<TR>
<TD id=menu2 onmouseover="document.all.menu2.bgColor='#5581D2'"
onmouseout="document.all.menu2.bgColor='#F1F1F1'" align=right
width="100%" height=15><B><a href="add.jsp">写留言</a></B></TD>
</TR>
<TR>
<TD id=menu3 onmouseover="document.all.menu3.bgColor='#5581D2'"
onmouseout="document.all.menu3.bgColor='#F1F1F1'" align=right
width="100%" height=15><B><a href="search.jsp">搜索留言</a></B></TD>
</TR>
<TR>
<TD id=menu4 onmouseover="document.all.menu4.bgColor='#5581D2'"
onmouseout="document.all.menu4.bgColor='#F1F1F1'" align=right
width="100%" height=2><B><a href="help.jsp">帮助</a></B></TD>
</TR>
</TBODY>
</TABLE>
<p> </p>
<p> </p></td>
<td valign="top" class="f12"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="5581d2">
<tr>
<td width="50%"><img src="images/images/page_index.gif" width="400" height="46"></td>
<td width="50%"><div align="right"><img src="images/images/pagetitle2_.gif" width="185" height="46"></div></td>
</tr>
</table>
<%
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);
//显示数据
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");
%>
<br>
<table width="95%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#969696" class="f12">
<tr>
<td width="200" rowspan="2" align="center" valign="top" bgcolor="#FFFFFF">
<div align="center">
<table width="100%" border="0" cellpadding="2" cellspacing="0" class="f12">
<tr>
<td colspan="2" align="center"><img src="images/face/<%=userface%>.gif" width="90" height="90"><br>
<br>
<font color="#333333"><strong><%=username%></strong></font></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td width="18"><img src="images/images/homepage.gif" width="18" height="18"></td>
<td width="181"><a href="<%=userurl%>" target="_blank"><%=userurl%></a></td>
</tr>
<tr>
<td><img src="images/images/email.gif" width="18" height="18"></td>
<td><a href="mailto:<%=usermail%>"><%=usermail%></a></td>
</tr>
<tr>
<td><img src="images/images/qq.gif" width="18" height="18"></td>
<td><%=userqq%></td>
</tr>
</table>
</div></td>
<td height="50" bgcolor="#FFFFFF">
<table width="100%" border="0" cellpadding="2" cellspacing="2" class="f12">
<tr>
<td><font color="#333333">标题:<%=usertitle%><br>
时间:<%=mydate%></font></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="150" valign="top" bgcolor="#FFFFFF">
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="f12">
<tr>
<td><font color="#333333"><%=content%></font></td>
</tr>
</table>
<%
if(recontent!=null)
{
%>
<table width="95%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#969696" class="f12">
<tr>
<td bgcolor="#FFFFFF"><font color="5581d2">管理员回复:<%=recontent%></font><br>
<font color="#6699CC">--------------------------------------------------------------------------------</font>
<br>
<font color="5581d2"><%=remydate%></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>
留言IP:<font color="#333333"><%=ip%></font></div></td>
</tr>
<%}%>
</table>
<br>
<%
Rs.next();
i++;
//读流言信息结束
}
Rs.close();
%>
<br>
<table width="100%" border="0" cellpadding="3" cellspacing="3" class="f12">
<tr>
<td width="50%"><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>
</tr>
</table></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="2" cellspacing="2" class="bian">
<tr>
<td style="BORDER-TOP: #969696 1px solid; FILTER: progid:DXImageTransform.Microsoft.Gradient(startColorStr='#5581D2', endColorStr='#FFFFFF', gradientType='1'" ><div align="right" class="f12"><font color="#333333">版权所有:WWW.JSPSKY.COM</font> <br>
</div></td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -