?? search.jsp
字號:
<%/** * $RCSfile: search.jsp,v $ * $Revision: 1.5 $ * $Date: 2002/09/30 20:22:27 $ */%><%@ page import="java.util.*, com.jivesoftware.util.*, com.jivesoftware.forum.*, com.jivesoftware.forum.util.*, com.jivesoftware.base.*" errorPage="error.jsp"%><% // Page Description: // // This page handles logging into the system as well as logouts.%><% // global.jsp - see description on index.jsp %><%@ include file="global.jsp" %><% // Get parameters: // The forum ID (optional) long forumID = ParamUtils.getLongParameter(request,"forum",-1L); // The query String queryText = ParamUtils.getParameter(request,"q"); // The starting index of results to show: int start = ParamUtils.getIntParameter(request,"start",0); // The number of results to show per page: int range = 15; // Optionally load a forum: Forum forum = null; try { forum = forumFactory.getForum(forumID); } catch (ForumNotFoundException ignored) {}%><%@ include file="header.html" %><jsp:include page="breadcrumbs.jsp" flush="true"> <jsp:param name="forum" value="<%= String.valueOf(forumID) %>" /></jsp:include><p>Use the form below to search the forum content.</p><form action="search.jsp" name="searchform"><input type="hidden" name="forum" value="<%= forumID %>"><table id="search-form" cellpadding="2" cellspacing="2" border="0" align="center"><tr> <td class="label"> Search For: </td> <td> <input type="text" name="q" size="60" maxlength="150"> </td></tr><tr> <td colspan="2" align="center" nowrap> <br> <input type="submit" value="Search!" class="main-button"> <input type="submit" value="Cancel" name="cancel" class="cancel-button"> </td></tr></table></form><% if (queryText != null) { // If a query was submitted, try running a search. First, create a // Query object and populate it (we fully qualify the Query object name // because some appservers have classes already named "Query"): com.jivesoftware.forum.Query query = null; // Next, determine if this is a global or local search. A global search // searches over all categories and forums and a local one will just search // a single forum. If the forum object is not null that means we should // search on a forum, otherwise we'll search globally. We specify these types // of searches based on how we create a query object: if (forum != null) { // local search: query = forum.createQuery(); } else { query = forumFactory.createQuery(); } // Now, set the query text: query.setQueryString(queryText); // Execute the query - this returns an Iterator of ForumMessages. Limit the // number of results we get to 'range' results and specify the starting // index of results (this allows us to paginate through the results): Iterator results = query.getResults(start, range); // If there were no results, print out a message: if (!results.hasNext()) {%> <p class="search-noresults"> No results for "<%= queryText %>" - please try different search terms. </p><% } else { // First, print a summary of the results:%> <p> Results: <%= query.getResultCount() %>, showing <%= range %> page page: </p> <% // Now, loop through all the results: int counter = start; while (results.hasNext()) { ForumMessage message = (ForumMessage)results.next(); counter ++; ForumThread searchThread = message.getForumThread(); Forum searchForum = searchThread.getForum(); %> <table class="search-result" cellpadding="2" cellspacing="2" border="0" width="100%"> <tr valign="top"> <td width="1%"> <%= counter %>) </td> <td width="99%"> <a href="thread.jsp?forum=<%= searchForum.getID() %>&thread=<%= searchThread.getID() %>" ><%= message.getSubject() %></a> </td> </tr> </table><% } // end of results while loop } // end of else } // end of if%><script language="JavaScript" type="text/javascript"><!--document.searchform.q.focus();//--></script><%@ include file="footer.html" %>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -