📄 search.jsp
字号:
<%@page contentType="text/html; charset=UTF-8"%>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@page import="javax.servlet.*, javax.servlet.http.*, java.io.*, org.apache.lucene.analysis.*, org.apache.lucene.document.*, org.apache.lucene.index.*, org.apache.lucene.search.*, org.apache.lucene.queryParser.*"%>
<%@page import="java.net.*"%>
<%@page import="com.laoer.bbscs.comm.*"%>
<jsp:useBean id="istartindex" scope="request" type="java.lang.Integer"/>
<jsp:useBean id="ithispage" scope="request" type="java.lang.Integer"/>
<jsp:useBean id="queryString" scope="request" type="java.lang.String"/>
<jsp:useBean id="hits" scope="request" type="org.apache.lucene.search.Hits"/>
<%
int startindex = istartindex.intValue();
int thispage = ithispage.intValue();
int maxpage = 50;
%>
<html>
<head>
<title>搜索结果</title>
<link href="css/css1.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<table width="100%" border="0" cellpadding="5" cellspacing="0">
<tr>
<td class="bgColor3">
<strong class="font1">搜索结果</strong>
您搜索的内容是 "<%=queryString%>" 大约有 <%=hits.length()%> 条符合条件的纪录
</td>
<td class="bgColor3"><div align="right">[<a href="javascript:history.go(-1);">返回</a>]</div></td>
</tr>
</table>
<%
if (hits.length() <= 0) {
%>
<table width="100%" border="0" cellpadding="5" cellspacing="0">
<tr>
<td>没有检索到匹配的内容!</td>
</tr>
</table>
<%
}
else {
if ((startindex + maxpage) > hits.length()) {
thispage = hits.length() - startindex;
}
for (int i = startindex; i < (thispage + startindex); i++) {
Document doc = hits.doc(i);
String doctitle = doc.get("title");
String summary = doc.get("summary");
String mainId = doc.get("mainId");
String createTime = doc.get("createTime");
String boardId = doc.get("boardId");
%>
<table width="80%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td>
<span class="font1"><a href="<%=BBSCSUtil.getActionMappingURL("/read?action=topic&id="+mainId+"&bid="+boardId,request)%>"><%=doctitle%></a></span>
</td>
</tr>
<tr>
<td><%=summary%></td>
</tr>
<tr>
<td>
<span class="font6">
<%=BBSCSUtil.absoluteActionURL(request,"/read?action=topic&id="+mainId+"&bid="+boardId)%>
</span>
</td>
</tr>
<tr>
<td height="10"> </td>
</tr>
</table>
<%
}
if ((startindex + maxpage) < hits.length()) {
String moreurl = BBSCSUtil.getActionMappingURL("/search?query=" + URLEncoder.encode(queryString, "UTF-8") + "&maxresults=" + maxpage +
"&startat=" + (startindex + maxpage),request);
out.println("<a href=" + moreurl + ">More Results</a>");
}
}
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -