JSP uses JSTL to implement page turning instance code

Time:2020-11-23

Using JSTL for display is more neat and less code than JSP

Copy codeThe code is as follows:
<%@page language=”java” contentType=”text/html; charset=UTF-8″ pageEncoding=”UTF-8″%>
<%@taglib prefix=”c”  uri = “http://java.sun.com/jsp/jstl/core”%>
<%@page import=”java.util.List”%>
<%@page session=”true”%>
<%@page errorPage=”error.jsp”%>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>
< title > retrieval
<script type=”text/javascript”>
 function validate1() {
  var page = document.forms[0].page.value;
  if (page.length <= 0) {
Please enter the number of pages to jump to! “”;
  } else if (isNaN(page)) {
Please enter a valid number of pages! “”;
  } else {
   document.forms[0].submit();
  }
 }
</script>
</head>
<body>
Retrieval time: < C: out value = “${ Result.costtime }” />
Total number of records: < C: out value = “${ Result.total }<br>” escapeXml=”false”/>
 <c:forEach items=”${Result.article}” var=”current” varStatus=”status”>
< br > the < C: out value = “${ status.count + ( Result.pageNum -1) * 20} / > bar
  <br>
Title: < C: out value = < a http: / / servletdetail? Rid=${ current.rowid }’>${ current.title }</a>” escapeXml=”false”></c:out>
< br > date: < C: out value = “${ current.date }”/>
 </c:forEach>
 <table width=”100%” border=”0″ align=”center” cellpadding=”0″
  cellspacing=”0″ bgcolor=”#8C8C8C”>
  <tr>
   <td height=”22″ align=”center” bgcolor=”#FFFFFF”>
< C: out value${ Result.pageNum }Page / “/ >
< C: out value = total${ Result.totalPage }Page “
< C: out value = total${ Result.total }Records “
   <c:if test=”${Result.pageNum<2 }”>
< C: out value = “home page | previous page” / >
   </c:if>
   <c:if test=”${Result.pageNum>=2 }”>
< C: out value = < a http: / / servletsearch? Page = ${1} & keyword = ${keyword} ‘> < a > “escapexml =” false “/ >
    <c:out value=”<a href=’servletSearch?page=${ Result.pageNum -1} & keyword = ${keyword} > > previous < / a > “escape XML =” false “/ >
   </c:if>
   <c:out value=”|”/>
   <c:if test=”${(Result.totalPage-Result.pageNum)<1 }”>
< C: out value = “next page | last page” / >
   </c:if>
   <c:if test=”${(Result.totalPage-Result.pageNum)>=1 }”>
    <c:out value=”<a href=’servletSearch?page=${ Result.pageNum +1} & keyword = ${keyword} next < / a > “escape XML = false” / >
    <c:out value=”<a href=’servletSearch?page=${ Result.totalPage }&Keyword = ${keyword} > > last page < / a > “escape XML = false” / >
   </c:if>
   <form action=”servletSearch” method=”post”>
    <input type=”text” name=”page”><input type=”hidden” name=”keyWord” value=${keyWord}>
< input type = “button” value = jump to “onclick =” validate1() “>”
   </form>
 </table>
</body>
</html>

Recommended Today

PHP 12th week function learning record

sha1() effect sha1()Function to evaluate the value of a stringSHA-1Hash. usage sha1(string,raw) case <?php $str = “Hello”; echo sha1($str); ?> result f7ff9e8b7bb2e09b70935a5d785e0cc5d9d0abf0 sha1_file() effect sha1_file()Function calculation fileSHA-1Hash. usage sha1_file(file,raw) case <?php $filename = “test.txt”; $sha1file = sha1_file($filename); echo $sha1file; ?> result aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d similar_text() effect similar_text()Function to calculate the similarity between two strings. usage similar_text(string1,string2,percent) case […]