📄 search.jsp
字号:
<script language=javascript>
<!--
var startTime,endTime;
var d=new Date();
startTime=d.getTime();
//-->
</script>
<html>
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page language="java" import="java.sql.*"%>
<%@ page language="java" import="java.util.*"%>
<jsp:useBean id="sqlbean" scope="page" class="news.sql_data"/>
<jsp:useBean id="getsql" scope="page" class="news.functions"/>
<head>
<title>企业内部管理信息平台∷搜索引擎</title>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<link rel="stylesheet" href="newstyle.css" type="text/css">
</head>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<body bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<div align=center>
<jsp:include page="header.jsp"/>
<BR style="OVERFLOW: hidden; LINE-HEIGHT: 3px">
<SCRIPT>
var old_bg="";
function inStyle(obj)
{
old_bg=obj.style.background;
obj.style.background="#FFFF99";
}
function outStyle(obj)
{
obj.style.background=old_bg;
}
</SCRIPT><%String kt=new String(request.getParameter("kt").getBytes("ISO8859_1"),"GBK");
String keyword=new String( request.getParameter("keyword").getBytes("ISO8859_1"),"GBK");
//声明变量,并取得所提交参数值和进行编码转换
String field=new String(request.getParameter("field").getBytes("ISO8859_1"),"GBK");
keyword=keyword.replaceAll("<","<");
//将提交过来的<字符进行替换,以免和HTML标记混淆
ResultSet RS=getsql.sql_search(field,kt,keyword);//调用模糊查找bean按照所选择条件生成sql语句并检索
%>
<TABLE width="780" border=0 align=center cellPadding=0 cellSpacing=0>
<tr>
<th align="left"> 你查找的关键字是: <font color=red><%=keyword%></font></th>
</tr><TR >
<TD><BR style="OVERFLOW: hidden; LINE-HEIGHT: 3px">
<table width="98%" border=0 align="center" cellpadding=4 cellspacing=1>
<tr >
<td height="22" width=65%> 标题 </td>
<td width=15% height="22" align=center nowrap >整理日期</td>
<td width=15% height="22" align=center nowrap >出处</td>
<td width=10% height="22" align=center nowrap >浏览次数</td>
</tr><%
//String sql = "Select * FROM news order by hit desc";
int intPageSize; //一页显示的记录数
int intRowCount; //记录总数
int intPageCount; //总页数
int intPage; //待显示页码
java.lang.String strPage;
//int i;
//设置一页显示的记录数
intPageSize = 15;
//取得待显示页码
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);
//显示数据
int i = 0;
while((i<intPageSize && !RS.isAfterLast())){%>
<TR onmouseover=inStyle(this) style="BACKGROUND: #F7F7F7" onmouseout=outStyle(this) >
<TD height=23> [<a href=list.jsp?sortid=<%=RS.getString("class")%>&rootid=<%=RS.getString("parentclass")%>><%=RS.getString("class")%></a>] <a href=show.jsp?id=<%=RS.getString("id")%>&keyword=<%=keyword%>>
<%=RS.getString("title").replaceAll(keyword,"<font color=red><b>"+keyword+"</b></font>")%></a></TD>
<TD noWrap align=center><%=RS.getDate("d")%></TD>
<TD noWrap align=center><%=RS.getString("author")%></TD>
<TD noWrap align=center><%=RS.getString("hit")%></TD>
</TR>
<%RS.next();
i++;}
}
RS.close();%>
<TR >
<TD height=22 colSpan=3>共找到<%=intRowCount%>条记录 第<%=intPage%>页/共<%=intPageCount%>页
<%if(intPage>1){%><a href="search.jsp?page=<%=intPage-1%>&keyword=<%=keyword%>&kt=<%=kt%>&field=<%=field%>">上一页</a><%}%>
<%if(intPage<intPageCount){%><a href="search.jsp?page=<%=intPage+1%>&keyword=<%=keyword%>&kt=<%=kt%>&field=<%=field%>">下一页</a><%}%>
请选择页码:<select name="page" onChange="MM_jumpMenu('parent',this,0)">
<option value="search.jsp?page=<%=intPage%>&keyword=<%=keyword%>&kt=<%=kt%>&field=<%=field%>" selected><%=intPage%></option>
<%int j;
for (j=1;j<=intPageCount;j++){%>
<option value="search.jsp?page=<%=j%>&keyword=<%=keyword%>&kt=<%=kt%>&field=<%=field%>"><%=j%></option>
<%}%>
</select></TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
<div align="center"><jsp:include page="bottom.jsp"/>
</div></div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -