把搜索页面index.jsp放到Tomcat中。
- <% if (!query.equals("")) { %>
- <jsp:useBean id="search" class="com.bitmechanic. spindle.Search" scope="application">
- <!-- Specify the directory that stores our Lucene index created by the spindle spider -->
- <% search.init("d:/index"); %>
- </jsp:useBean>
- <jsp:setProperty name="search" property="query"/>
- <list:init name="customers" listCreator="search" max="10">
- <hr>
- <list:hasResults>
- <list:iterate>
- <TABLE width="65%">
- <TR>
- <TD>
- <a href="<list:iterateProp property="url"/>">
- <B><FONT style="FONT-SIZE: 14px"><list: iterateProp property="title"/></FONT></B></a>
- <FONT size=-1 color=#6f6f6f> (<list:iterateProp property="source"/>) <list:iterateProp property="accessDate"/></FONT>
- </TD>
- </TR>
- <TR>
- <TD>
- <FONT size=-1><list:iterateProp
- property="desc"/></FONT>
- </TD>
- </TR>
- </TABLE>
- </list:iterate>
- <pg:pager
- url="/index.jsp"
- items="<%=Integer.parseInt(listSize)%>"
- maxPageItems="10"
- maxIndexPages="10"
- export="currentPageNumber=pageNumber"
- scope="request">
- <pg:param name="query" value="<%=query%>"/>
- <pg:index export="totalItems=itemCount">
- <pg:page export="firstItem, lastItem">
- <div class="resultInfo">
- 当前显示结果 <strong><%= firstItem %>-<%= lastItem %></strong> 找
- 到相关文档 <strong><%=listSize%></strong> 篇
- </div>
- </pg:page>
- <div class="rnav">
- <table border=0 cellpadding=0 width=1% cellspacing=0 align=
- center><tr align=center valign=top>
- <td valign=bottom nowrap><font size=-1>结果页码:
- <pg:first unless="current">
- <td nowrap><a href="<%= pageUrl %>" class="rnavLink">
- <nobr>首页</nobr></a>
- </pg:first>
- <pg:prev export="pageUrl">
- <td nowrap><a href="<%= pageUrl %>" class="rnavLink">&#
- 171; 上一页</a>
- </pg:prev>
- <pg:pages><%
- if (pageNumber.intValue() < 10) {
- %> <%
- }
- if (pageNumber == currentPageNumber) {
- %><b><%= pageNumber %></b><%
- } else {
- %><td nowrap> <a href="<%= pageUrl %>"><%=
- pageNumber %></a> <%
- }
- %>
- </pg:pages>
- <pg:next export="pageUrl">
- <td nowrap><a href="<%= pageUrl %>" class=
- "rnavLink">下一页 »</a>
- </pg:next>
- <pg:last unless="current">
- <td nowrap><a href="<%= pageUrl %>" class=
- "rnavLink"><nobr>末页</nobr></a>
- </pg:last>
- </table>
- </div>
- </pg:index>
- </pg:pager>
- </list:hasResults>
- <list:hasNoResults>
- 对不起,没有结果返回。<p>建议你换用更少的文字查询以扩大搜索范围。
- </list:hasNoResults>
- </list:init>
- <% } %>
需要使用Tomcat的版本为5.5.X或6.0。为了让Tomcat 支持中文,要修改server.xml文件。设置值URIEncoding:
- <Connector port="8080" maxThreads="150" minSpareThreads="25"
- maxSpareThreads="75" enableLookups="false" redirectPort="8443"
- acceptCount="100" debug="0" connectionTimeout="20000"
- disableUploadTimeout="true" URIEncoding="UTF-8" useBodyEncodingForURI= "true" />
同时修改WEB-INF目录下的web.xml文件,设置Filter:
- <filter>
- <filter-name>Set Character Encoding</filter-name>
- <filter-class>filters.SetCharacterEncodingFilter</filter-class>
- <init-param>
- <param-name>encoding</param-name>
- <param-value>utf-8</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>Set Character Encoding</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>



