📄 search.jsp
字号:
<%@page language="java" contentType="text/html;charset=GBK"%>
<%@page import="java.io.*,java.sql.*,java.util.*,java.text.*,oa.main.*"%>
<%
oa.bean.MainBean myBean = null;
try{
myBean = new oa.bean.MainBean();
//session.setAttribute("UID","11");
DealString ds = new DealString();
//取得菜单类别
String strId1 = ds.toString((String)request.getParameter("txt_type1"));
String strId2 = ds.toString((String)request.getParameter("txt_type2"));
if(strId1.equals(""))strId1 = "1";
if(strId2.equals(""))strId2 = "0";
int intId1 = Integer.parseInt(strId1);
String strMenuName = myBean.toMenu1(strId1);
String strMenuName2 = myBean.toMenu2(strId1,strId2);
String strFileId = ds.toString((String)request.getParameter("txt_fileid"));
if(strFileId.equals(""))strFileId = "0";
String strSub = ds.toString((String)request.getParameter("txt_sub"));
if(strSub.equals("")) strSub="0";
String wtb = "";
if(Integer.parseInt(strSub)>3) wtb = "0";
else wtb = "1";
String strEdit = ds.toString((String)request.getParameter("txt_edit"));
if(strEdit.equals("")) strEdit = "0";
String strmenuid = ds.toString((String)request.getParameter("txt_menuid"));
if(strmenuid.equals("")) strmenuid = "0";
String strtopicid = ds.toString((String)request.getParameter("txt_topicid"));
if(strtopicid.equals("")) strtopicid = "0";
String strsearch = ds.toString((String)request.getParameter("txt_search"));
if(strsearch.equals("")) strsearch="0";
String keyword = ds.toGBK((String)request.getParameter("keyword"));
String s1 = ds.toString((String)request.getParameter("s1"));
String s2 = ds.toString((String)request.getParameter("s2"));
if(s2.equals("")) s2="all";
String curpage = ds.toString((String)request.getParameter("topage1"));
int topage = 1;
if(!curpage.equals(""))
topage = Integer.parseInt(curpage);
Vector vt = (Vector)myBean.search1(keyword,s1,s2,curpage);
String strtotal = ds.toString((String)vt.get(0));
//if(!strtotal.equals(""))total = Integer.parseInt(strtotal);
int total = Integer.parseInt((String)vt.get(0));
int tpage = Integer.parseInt((String)vt.get(1));
if(vt.size()>=2)
{
String strtpage = ds.toString((String)vt.get(1));
if(!strtpage.equals(""))tpage = Integer.parseInt(strtpage);
}
int aa = 0;
int j1=vt.size();
String str1Id [] = new String[j1];
String str1title[] = new String[j1];//文章标题
String str1time[] = new String[j1];//发表时间
String str1Hits[] = new String[j1];//取得数标题是信息
for(int i1=2;i1<vt.size();i1++)
{
Hashtable hash = (Hashtable)vt.get(i1);
str1Id[i1] = (String)hash.get("ID");
str1title[i1] = (String)hash.get("TITLE");
str1time[i1] = ((String)hash.get("ADDTIME")).substring(0,10);
str1Hits[i1] = (String)hash.get("HITS");
}
int wlen=21;
String color_time = "#616161";
//取得CSS
String css = (String)session.getAttribute("CSS");
int st1=0;
int st2=0;
%>
<LINK href="../css/child.css" type=text/css rel=stylesheet>
<div align="center">
<table border="0" cellPadding="0" cellSpacing="0" width="790" background="../images/bg01.gif">
<tbody>
<tr vAlign=top>
<TD align=right>
<table border="0" cellPadding="0" cellSpacing="0" width="779">
<tbody>
<tr vAlign=top>
<TD align=right width=180>
<TABLE cellSpacing=0 cellPadding=0 width=173 border=0>
<TBODY>
<TR>
<TD align=right vAlign=top bgColor=#f7fbff>
<TABLE cellSpacing=0 cellPadding=0 width=172 border=0>
<TBODY>
<TR><TD vAlign=top align=right><IMG height=26 src="../images/search.gif" width=172></TD></TR>
<TR>
<TD vAlign=top align=middle><br>
<TABLE width=123 border=0>
<TBODY>
<TR><TD align=middle><INPUT class=inputter size=16 value="关键字:" name="keyword" onkeydown="if(window.event.keyCode==13)search2();"></TD></TR>
<TR><TD align=middle>
<select style="WIDTH: 123px" name=select2>
<option value="1" selected>标题</option>
<option value="2">关键字</option>
</select>
</TD></TR>
<TR><TD align=middle>
<SELECT style="WIDTH: 123px" name="s2">
<option value="all" selected>所有时间</option>
<option value="1">昨天以来</option>
<option value="3">3 天以来</option>
<option value="7">7 天以来</option>
<option value="15">15天以来</option>
<option value="30">30天以来</option>
<option value="60">60天以来</option>
<option value="90">90天以来</option>
</SELECT>
</TD></TR>
<TR><TD align=right><IMG style="cursor:hand;" height=17 src="../images/index_top_search.gif" width=49 onclick="search2()"></TD></TR>
<TR><TD align=middle> </TD></TR>
</TBODY>
</TABLE>
</TD></TR>
</TBODY>
</TABLE>
</TD>
<TD align=left valign=top background="../images/index_right2_bg02.gif">
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR><TD vAlign=top align=left><IMG height=9 src="../images/index_right2_top.gif"></TD></TR>
<TR><TD vAlign=top align=left background="../images/index_right2_bg02.gif">
<TABLE cellSpacing=5 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=top align=left>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<tr height="5" valign=top>
<td height="5" align=left style="LINE-HEIGHT: 150%"> 当前位置:<a class=MOUT href="index.jsp">首页</a>
>> 文章搜索</td>
</tr>
<TR><TD vAlign=top align=left>
<TABLE height=20 cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD align=middle width=30><IMG height=10 src="../images/index_right2_arrow.gif" width=10></TD>
<TD style="LINE-HEIGHT: 150%"><STRONG><font color="#1258af">
您搜索的关键字:</font><font color=red><b><%=keyword%></b></font></STRONG></TD>
<TD align=right></TD></TR>
</TBODY></TABLE>
</TD></TR>
<TR><TD vAlign=top align=left background="../images/index_right2_line02bg.gif"><IMG height=3 src="../images/index_right2_line02.gif" width=288></TD></TR>
<%if(total==0)
{
%>
<tr align=center><td><font color=red><br>没有搜索到任何结果!<br><br></font></td></tr>
<TR><TD vAlign=top align=left><IMG height=1 src="../images/index_right2_line04.gif" width=284></TD></TR>
<%
}
else
{
int t = vt.size();
for(int i=2;i<t;i++)
{
String title = (String)((Hashtable)vt.get(i)).get("TITLE");
keyword = ds.toString(keyword);
String str[] = ds.splitStr(ds.toString(keyword),' ');
if(s1.equals("1"))
{
for(int h=0;h<str.length;h++)
{
String newword = "<font color=red>"+str[h]+"</font>";
title = title.replaceAll(str[h],newword);
}
}
String img = "index_right2_line04.gif";
String w = "284";
if(i!=(t-1))
{
img = "index_right2_line03.gif";
w = "253";
}
%>
<TR><TD vAlign=top align=left>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=top align=left>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD align=middle width=30 height=25><IMG height=10 src="../images/index_right2_arrow02.gif" width=10></TD>
<TD><a onclick="view('<%=str1Id[i]%>');" style="cursor:hand;line-height:130%;" target=_blank title=<%=str1Hits[i]%>><%=title%></a> <font color=<%=color_time%>>(<%=str1time[i]%>)</font></TD></TR>
</TBODY></TABLE>
</TD></TR>
<TR><TD vAlign=top align=left><IMG height=1 src="../images/<%=img%>" width="<%=w%>"></TD></TR>
</TBODY></TABLE>
</TD></TR>
<%
}//for_end
}
%>
<tr height=18 valign=bottom>
<TD align=right><br>
共有记录数:<font color=red><%=total%></font>
当前<font color=red><%=topage%></font>/<%=tpage%>页   <%if(topage!=1){%><a onclick="firsrpg()" style="cursor:hand">第一页    </a> <%}%>
<%if(topage>1){ st1=topage-1;%>
<a onclick="lastpg()" style="cursor:hand">上一页    </a><%}%>
<%if(topage<tpage){ st2=topage+1;%>
<a onclick="nextpg()" style="cursor:hand">下一页   </a><%}%>  
<%if(topage<tpage){%>
<a onclick="finalpg()" style="cursor:hand">最后页    </a>
<%}%>
</TD>
</tr>
</TBODY>
</TABLE>
</TD></TR>
</TBODY>
</TABLE>
</TD>
</TR>
</TBODY></TABLE>
</TD>
</TR>
</TBODY></TABLE>
</TD></TR>
</TBODY></TABLE>
<table border="0" cellPadding="0" cellSpacing="0" width="790" background="../images/bg01.gif">
<tbody>
<tr vAlign=top>
<TD align=center valign=top>
<table border="0" cellPadding="0" cellSpacing="0" width="779">
<tbody>
<tr>
<TD vAlign=top align=right width=180 height=15><IMG height=15 width=172 src="../images/down1.gif"></td>
<td vAlign=bottom background="../images/index_right2_bg02.gif"><IMG height=9 src="../images/index_right2_down.gif"></td>
</TR>
</TBODY></TABLE>
</TD></TR>
</TBODY></TABLE>
</div>
<script>
function firsrpg()
{
document.all.txt_type1.value = "<%=strId1%>";
document.all.txt_type2.value = "<%=strId2%>";
document.all.keyword.value="<%=keyword%>";
document.all.s1.value="<%=s1%>";
document.all.s2.value="<%=s2%>";
document.all.txt_search.value = "search.jsp?"+"<%=keyword%>";
document.all.form1.action = "index.jsp?topage1=1";
document.all.form1.submit();
}
function lastpg()
{
document.all.txt_type1.value = "<%=strId1%>";
document.all.txt_type2.value = "<%=strId2%>";
document.all.keyword.value="<%=keyword%>";
document.all.s1.value="<%=s1%>";
document.all.s2.value="<%=s2%>";
document.all.txt_search.value = "search.jsp?"+"<%=keyword%>";
document.all.form1.action = "index.jsp?topage1="+<%=st1%>;
document.all.form1.submit();
}
function nextpg()
{
document.all.txt_type1.value = "<%=strId1%>";
document.all.txt_type2.value = "<%=strId2%>";
document.all.keyword.value="<%=keyword%>";
document.all.s1.value="<%=s1%>";
document.all.s2.value="<%=s2%>";
document.all.txt_search.value = "search.jsp?"+"<%=keyword%>";
document.all.form1.action = "index.jsp?topage1="+<%=st2%>;
document.all.form1.submit();
}
function finalpg()
{
document.all.txt_type1.value = "<%=strId1%>";
document.all.txt_type2.value = "<%=strId2%>";
document.all.keyword.value="<%=keyword%>";
document.all.s1.value="<%=s1%>";
document.all.s2.value="<%=s2%>";
document.all.txt_search.value = "search.jsp?"+"<%=keyword%>";
document.all.form1.action = "index.jsp?topage1="+<%=tpage%>;
document.all.form1.submit();
}
function search2()
{
if(document.all.keyword.value=="")
{
alert("请输入关键字!");
return false;
}
document.all.txt_type1.value = "<%=strId1%>";
document.all.txt_type2.value = "<%=strId2%>";
document.all.txt_search.value = "search.jsp?"+"<%=keyword%>";
document.all.form1.action="index.jsp?topage1=1";
document.all.form1.submit();
}
function search1()
{
document.all.txt_type1.value = "<%=strId1%>";
document.all.txt_type2.value = "<%=strId2%>";
document.all.keyword.value="<%=keyword%>";
document.all.s1.value="<%=s1%>";
document.all.s2.value="<%=s2%>";
document.all.txt_search.value = "search.jsp?"+"<%=keyword%>";
document.all.form1.action="index.jsp";
document.all.form1.submit();
}
function view(id)
{
document.all.txt_type1.value = "<%=strId1%>";
document.all.txt_type2.value = "<%=strId2%>";
document.all.txt_fileid.value = id;
document.all.txt_edit.value = "";
document.all.txt_menuid.value = "";
document.all.txt_topicid.value = "";
document.all.txt_search.value = "";
//document.all.form1.action = "index.jsp";
//document.all.form1.submit();
var hWnd = window.open("index.jsp?txt_fileid="+id+"&txt_type1="+document.all.txt_type1.value+"&txt_type2="+document.all.txt_type2.value,"help");
hWnd.focus();
}
</script>
<% }finally{
if(myBean!=null)myBean.closeConn();
}
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -