简体   繁体   中英

display results in search engine (no MySQL)

I am developing a search engine in java.It works fine but all results are displayed in one page.How can I display results in separate pages like google. If I have 100 results then the results will be displayed in say 10 pages 10 results each. I am not using MySQL. My data is stored in files.

So you need to take the specified page number and use that to work out which result to display first in that page.

say your URL looked like this

www.yoursite.com?search=JSP&page=3

Then, you'd extract the search term and find the results. You'd also get the requested page and use it.

firstResultNum = page * resultsPerPage
for (i=firstResultNum; i<firstResultNum+resultsPerPage; i++)
{
  displayCurSearchResult(i);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM