Use jsp to achieve the most basic page flip:
<% @ Page import = "java. util. arrayList "%> <% @ page import =" serchJava. trssearcher. articleBean "%> <% @ page import =" java. util. list "%> <% @ page language =" java "contentType =" text/html; charset = UTF-8 "pageEncoding =" UTF-8 "%> <% @ page session =" true "%> <% @ page errorPage =" error. jsp "%>
Search<Script type = "text/javascript"> function validate1 () {var page = document. forms [0]. page. value; if (page. length <= 0) {alert ("Enter the number of pages to jump! ");} Else if (isNaN (page) {alert (" enter a valid page number! ") ;}Else {document. forms [0]. submit () ;}}</script>
<% String str = request. getParameter ("keyWords"); String strWhere = "Title =" + str + "or body =" + str; int intPage = 0; // page number to be displayed // obtain the page number to be displayed String strPage = request. getParameter ("page"); if (strPage = null) // indicates that the page parameter is not found in QueryString, and the first page of data is displayed {intPage = 1 ;} else {intPage = java. lang. integer. parseInt (strPage); if (intPage <1) {intPage = 1 ;}} sResult = searchBean. searchList (strWhere, intPage); int intRowCount = (int) sResult. getTotal (); out. println ("Retrieval time:" + sResult. getCosttime () +"
"); Out. println (" Total number of records: "+ intRowCount +"
"+"
"); Int PgFirst = (intPage-1) * 20 + 1; // The first entry of the number of pages to be displayed List articleList = sResult. getArticleBeans (); // get the title list object int intPageCount = sResult. getPageNum (); // obtain the total number of pages for (int I = 0; I <articleList. size (); I ++) {ArticleBean article = new ArticleBean (); article = articleList. get (I); String strTitle = article. getTitle (); String rowid = article. getRowid (); out. println ("no." + PgFirst + ":" +"
"); %> Title:"> <% = strTitle %> <% out. println ("
"+" Date: "+ article. getDate () +"
"); PgFirst ++ ;}%>
<% = IntPage %> page/total <% = intPageCount %> page total <% = intRowCount %> records <% if (intPage <2) {out. print ("homepage | previous page ");} else {%> & keyWords = <% = str %> "> homepage | & keyWords = <% = str %>"> previous page <% }%> | <% if (( intPageCount-intPage) <1) {out. print ("next page | last page ");} else {%> & keyWords = <% = str %> "> next page | & keyWords = <% = str %>"> last page <%} %>
|
Can refer to the use of jstl after the effect, http://blog.csdn.net/redeagle_gbf/article/details/17168131
Compared with jstl, it is found that the amount of code used and the use effect are much better.