Jstl + EL + JSP paging Program

Source: Internet
Author: User

Today, I read a lot of paging programs, which are just too complicated. I can't write more simply, so I spent more than an hour writing a maple leaf program of jstl + EL + JSP. The code is quite simple and easy to understand, it is also easy to modify to your own paging program. First paste the code to see:

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><%@include file="inner/jstl.jsp"%><%@include file="inner/DataSource.jsp"%><%    if (request.getParameter("currentPage") == null)                    {                        pageContext.setAttribute("currentPage",                                new Integer(0));                                           } else                    {                        pageContext.setAttribute("currentPage", request                                .getParameter("currentPage"));                    }%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

---------------------------------------------------

Jstl. jsp page:

<% @ Taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "C" %> <% @ taglib uri = "http://java.sun.com/jsp/jstl/fmt" prefix = "FMT" %> <% @ taglib uri = "http://java.sun.com/jsp/jstl/functions "prefix =" functions "%> <% @ taglib uri =" http://java.sun.com/jsp/jstl/ SQL "prefix =" SQL "%> <% @ taglib uri =" http://java.sun.com/jsp/jstl/xml "prefix =" X "%> datasource. JSP page: <SQL: setdatasource url = "JDBC: mysql: // localhost: 3306/News" driver = "com. mySQL. JDBC. driver "user =" *** "Password =" ***** "/>

The following describes some variables:
Suppose you have 26 records and you want to display 5 records on each page, you need 6 pages.
Currentpage is any page in Sign 6, which is achieved through hyperlinks.
Resultnum is all 26 records.
Perpagenum number of records to be displayed on each page

OK, you can. You can modify the database and run it to see the effect.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.