<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" %>
<% request.setCharacterEncoding("gb2312");%>
<jsp:useBean id="DBConnection" scope="page" class="com.guestbook.DBConnection"/>
<%
Boolean a=(Boolean)session.getAttribute("a");
String search=request.getParameter("search");
String keyword=request.getParameter("key");
String s;
byte temp[];
try{
temp=keyword.getBytes("iso-8859-1");
s=new String(temp);
}
catch(Exception e){}
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>留言本-搜索留言</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">
<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>
<script language="javascript">
function check(){
if(post.key.value==""){
alert("请输入搜索关键字!");
return false;
}
if(post.key.value.length>20){
alert("您的称呼不超过20位");
return false;
}
return true;
}
</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>
</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=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>
</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>
<%
if (search==null)
{
%>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="f12">
<tr>
<td align="center"> </td>
</tr>
<tr>
<td><p> <br>
</p>
<P align=center>请输入要搜索的内容:<BR>
<BR>
<FORM action=search.jsp?search=search method=post name="post" id="post" onsubmit="return check();">
<INPUT type=text name=key >
<INPUT name="submit" type=submit value=搜索>
</FORM>
搜索范围将包括:留言者的正文以及回复内容关键字。
<p></P>
<p><br>
<br>
</p></td>
</tr>
</table>
<%}else{
request.setCharacterEncoding("gb2312");
String sql="select * from Guestbook where content like '%"+keyword+"%' or recontent like '%"+keyword+"%' order by id DESC";
ResultSet Rs=stmt.executeQuery(sql);
int intPageSize; //一页显示的记录数
int intRowCount; //记录总数
int intPageCount; //总页数
int intPage; //待显示页码
String strPage;
int i;
//设置一页显示的记录数
intPageSize = 3;
//取得待显示页码
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><img src="images/images/email.gif" width="18" height="18"></td>
<td><a href="mailto:<%=usermail%>"><%=usermail%></a></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++;
//读流言信息结束
}
%>
<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="search.jsp?page=1&search=search&key=<%=request.getParameter("key")%>">首页 </a> | <a href="search.jsp?page=<%=intPage-1%>&search=search&key=<%=request.getParameter("key")%>">上一页</a>
<%}%>
|
<%
if((intPageCount-intPage)<1)
{
out.print("下一页 | 尾页");
}else{%>
<a href="search.jsp?page=<%=intPage+1%>&search=search&key=<%=keyword%>">下一页</a> | <a href="search.jsp?page=<%=intPageCount%>&search=search&key=<%=request.getParameter("key")%>">尾页</a>
<%}
}
else{}
%>
</div></td>
</tr>
</table>
<%}
if(conn!=null)
{
conn.close();
}
if(stmt!=null)
{
stmt.close();
}
%></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="center" class="f12"><font color="#333333">版权所有:<br>电话:0531-85685878</font> <br>
</div></td>
</tr>
</table>
</body>
</html>
这是我用jsp写的一个网页,但是在两个页面之间之间转换时总是传不过中文参数过去。请各位高手帮以下忙。
当点击下一页时就不能从数据库里面读数据了,读的数据都是空值。