nutch 分页 翻页 已成功

来源:互联网 发布:mac版本不支持银联 编辑:程序博客网 时间:2024/05/21 08:02

搜索引擎nutch在查询搜索结果时,只有下一页功能。现在实现了分页功能,并把是show all hits删去

1.删去show all hits
修改:
         int hitsPerSite = 0; // max hits per site
2.分页功能
      <table align="center">
            <tr>
            <td>
                    <%
                        if (start >= hitsPerPage) // more hits to show
                        {
                    %>
                    <form name="pre" action="../search.jsp" method="get">
                        <input type="hidden" name="query" value="<%=htmlQueryString%>">
                        <input type="hidden" name="lang" value="<%=queryLang%>">
                        <input type="hidden" name="start" value="<%=start - hitsPerPage%>">
                        <input type="hidden" name="hitsPerPage" value="<%=hitsPerPage%>">
                        <input type="hidden" name="hitsPerSite" value="<%=hitsPerSite%>">
                        <input type="hidden" name="clustering" value="<%=clustering%>">
                        <input type="submit" value="上一页">
                        <%} %>
                    </form>
                    <%
                    int startnum=1;//页面中最前面的页码编号,我设定(满足)共10页,当页为第6页
                    if((int)(start/hitsPerPage)>=5)
                    startnum=(int)(start/hitsPerPage)-4;
                    for(int i=hitsPerPage*(startnum-1),j=0;i<=hits.getTotal()&&j<=10;)
                    {
                     %>
                     <td>
                     <form name="next" action="../search.jsp" method="get">
                        <input type="hidden" name="query" value="<%=htmlQueryString%>">
                        <input type="hidden" name="lang" value="<%=queryLang%>">
                        <input type="hidden" name="start" value="<%=i%>">
                        <input type="hidden" name="hitsPerPage" value="<%=hitsPerPage%>">
                        <input type="hidden" name="hitsPerSite" value="<%=hitsPerSite%>">
                        <input type="hidden" name="clustering" value="<%=clustering%>">
                        <input type="submit" value="<%=i/hitsPerPage+1 %>">
                    </form>
                    </td>
                    <%
                    i=i+5;
                    j++;
                    }
                     %>
                <td>
                    <%
         if ((hits.totalIsExact() && end < hits.getTotal()) // more hits to show
                                || (!hits.totalIsExact() && (hits.getLength() > start
                                + hitsPerPage))) {
                    %>
                   
                    <form name="next" action="../search.jsp" method="get">
                        <input type="hidden" name="query" value="<%=htmlQueryString%>">
                        <input type="hidden" name="lang" value="<%=queryLang%>">
                        <input type="hidden" name="start" value="<%=end%>">
                        <input type="hidden" name="hitsPerPage" value="<%=hitsPerPage%>">
                        <input type="hidden" name="hitsPerSite" value="<%=hitsPerSite%>">
                        <input type="hidden" name="clustering" value="<%=clustering%>">
                        <input type="submit" value="<i18n:message key="next"/>">//下一页
                    </form>
                    <%} %>
                    </td>
                  </tr>
                    </table>

原创粉丝点击