0 Comments

发布运行(5分钟)

发布于:2013-01-17  |   作者:广州网站建设  |   已聚集:人围观

把搜索页面index.jsp放到Tomcat中。


  1. <% if (!query.equals("")) { %>  
  2.   <jsp:useBean id="search" class="com.bitmechanic. spindle.Search" scope="application">  
  3.   <!-- Specify the directory that stores our Lucene  index created by the  spindle spider -->  
  4.   <% search.init("d:/index"); %>  
  5.   </jsp:useBean>  
  6.   <jsp:setProperty name="search" property="query"/>  
  7.   <list:init name="customers"  listCreator="search" max="10">  
  8.   <hr>  
  9.   <list:hasResults>  
  10.         <list:iterate>  
  11.                  <TABLE width="65%">  
  12.                         <TR>  
  13.                         <TD>  
  14.                              <a href="<list:iterateProp  property="url"/>">  
  15.                              <B><FONT style="FONT-SIZE:  14px"><list: iterateProp property="title"/></FONT></B></a>  
  16.                              &nbsp;&nbsp;<FONT size=-1  color=#6f6f6f> (<list:iterateProp property="source"/>) &nbsp;&nbsp;<list:iterateProp property="accessDate"/></FONT>  
  17.                         </TD>  
  18.                         </TR>  
  19.                         <TR>  
  20.                                 <TD>  
  21.                                         <FONT size=-1><list:iterateProp  
  22.                                         property="desc"/></FONT>  
  23.                                 </TD>  
  24.                         </TR>  
  25.                 </TABLE>  
  26.                 </list:iterate>  
  27.         <pg:pager  
  28.                 url="/index.jsp" 
  29.                 items="<%=Integer.parseInt(listSize)%>" 
  30.                 maxPageItems="10" 
  31.                 maxIndexPages="10" 
  32.                 export="currentPageNumber=pageNumber" 
  33.                 scope="request">  
  34.  
  35.           <pg:param name="query" value="<%=query%>"/>  
  36.             
  37.         <pg:index export="totalItems=itemCount">  
  38.  
  39.         <pg:page export="firstItem, lastItem">  
  40.         <div class="resultInfo">  
  41.         当前显示结果 <strong><%= firstItem %>-<%= lastItem %></strong> 找  
  42.         到相关文档 <strong><%=listSize%></strong> 篇  
  43.         </div>  
  44.         </pg:page>  
  45.  
  46.         <div class="rnav">  
  47.         <table border=0 cellpadding=0 width=1% cellspacing=0 align=   
  48.         center><tr align=center valign=top>  
  49.                 <td valign=bottom nowrap><font size=-1>结果页码:&nbsp;  
  50.  
  51.                 <pg:first unless="current">  
  52.                 <td nowrap><a href="<%= pageUrl %>" class="rnavLink">   
  53.                 <nobr>首页</nobr></a>  
  54.                 </pg:first>  
  55.  
  56.                 <pg:prev export="pageUrl">  
  57.                 <td nowrap><a href="<%= pageUrl %>" class="rnavLink">&#   
  58.                 171;&nbsp;上一页</a>&nbsp;  
  59.                 </pg:prev>  
  60.  
  61.                 <pg:pages><%  
  62.                   if (pageNumber.intValue() < 10) {   
  63.                         %>&nbsp;<%  
  64.                   }  
  65.                   if (pageNumber == currentPageNumber) {   
  66.                         %><b><%= pageNumber %></b><%  
  67.                   } else {   
  68.                         %><td nowrap>&nbsp;<a href="<%= pageUrl %>"><%=   
  69.                         pageNumber %></a>&nbsp;<%  
  70.                   }  
  71.                 %>  
  72.                 </pg:pages>  
  73.  
  74.                 <pg:next export="pageUrl">  
  75.                 &nbsp;&nbsp;<td nowrap><a href="<%= pageUrl %>" class=   
  76.                 "rnavLink">下一页&nbsp;&#187;</a>  
  77.                 </pg:next>  
  78.  
  79.                 <pg:last unless="current">  
  80.                 &nbsp;<td nowrap><a href="<%= pageUrl %>" class=   
  81.                 "rnavLink"><nobr>末页</nobr></a>  
  82.                 </pg:last>  
  83.         </table>  
  84.         </div>  
  85.  
  86.         </pg:index>  
  87.  
  88.         </pg:pager>  
  89.  
  90.         </list:hasResults>  
  91.  
  92.         <list:hasNoResults>  
  93.                 对不起,没有结果返回。<p>建议你换用更少的文字查询以扩大搜索范围。  
  94.         </list:hasNoResults>  
  95.  
  96.   </list:init>  
  97.     
  98. <% } %> 

需要使用Tomcat的版本为5.5.X或6.0。为了让Tomcat 支持中文,要修改server.xml文件。设置值URIEncoding:


  1. <Connector port="8080" maxThreads="150" minSpareThreads="25" 
  2.  maxSpareThreads="75" enableLookups="false" redirectPort="8443"   
  3. acceptCount="100" debug="0" connectionTimeout="20000" 
  4. disableUploadTimeout="true" URIEncoding="UTF-8"  useBodyEncodingForURI= "true" /> 

同时修改WEB-INF目录下的web.xml文件,设置Filter:


  1. <filter>  
  2.     <filter-name>Set Character Encoding</filter-name>  
  3.     <filter-class>filters.SetCharacterEncodingFilter</filter-class>  
  4.     <init-param>  
  5.         <param-name>encoding</param-name>  
  6.         <param-value>utf-8</param-value>  
  7.     </init-param>  
  8. </filter>  
  9. <filter-mapping>  
  10.     <filter-name>Set Character Encoding</filter-name>  
  11.     <url-pattern>/*</url-pattern>  
  12.     </filter-mapping> 
本节通过使用Lucene实现了一个可以在互联网上发布的搜索引擎,而世界上最大的互联网搜索引擎来自Google。
标签:
飞机