Java Web page Paging implementation

Source: Internet
Author: User
Tags java web

The effect of paging implementation:

/////////

/////////////////////////////////////////////////////// ////////////////////////////////////////////////  //////// //////////////////////////////////////////////////////////////////  ///////////////////////////////////////////// /////////////////////////////////////////

/////

////////////////////

One, from the effect can be seen from two parts of the content:

1. Student Information
2. Page number query (when the current page number is the first or last page.) Not clickable. This content will be written in detail in the tab.jsp file)

Second, the main knowledge is:

JDBC database connection, Java Basic class interface and generics knowledge, JSP, Servlet, XML

Third, the platform used here for the MyEclipse database for MySQL (also available other)

SPRINGMVC Architecture MVC (model-view-controller)

Iv. Detailed implementation

First, the JDBC related operations:

New database MYSQL2, new table student

(1) Information of the table

(2) types and lengths of the properties of the table

////////////

Paging implementation is

Querying the contents of a database table through the server on a browser enables paging

After the table information for the database is processed, create a new Web project

Under/webroot/web-inf/lib, import the jar for the database connection package/webroot/web-inf/lib/mysql-connector-java-5.0.3-bin.jar

New package file name, package name customization under SRC (new class, Package, JSP, Servlet, and other named customizations below)

1. Create the class DBO in the built-in package pers.ms.rfeng.util for the platform to connect to the database. The code is as follows:

The new test connection is successful, such as the following code:


New student class and generic class code such as the following

////////

/     ////////

Student information class corresponding to the DAO package

New interface Studentdao, write a method to be implemented by page query content Findbypage ().

At the same time, the new class Studentdaoimpl implements the interface.

The corresponding code such as the following:

Code//////////////////////////////////////to implement the interface

The new class Studentservice class invokes methods for querying content by page.

The code is as follows:

New jump page index.jsp code such as the following

Create a new servlet named Studentservlet to handle the reception of commands or data from the view

The code is as follows:

/////////////////////////////////////////

Studentservlet the corresponding message in the jump interface. A JSP is a view of what the beginning effect shows.

The code is as follows:

The jump Bar of the page number is tab.jsp,

The code is as follows:

Last configuration file Web. xml

(Description: This file is general.) The MyEclipse is self-generated, and eclipse needs to create its own code to write.

The code is as follows:

<?xml version= "1.0" encoding= "UTF-8"?

><web-app xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xmlns= "Http://java.sun.com/xml/ns/javaee" xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id= " webapp_id "version=" 3.0 "> <display-name>Manager</display-name> <servlet> <description> This is the description of my EE component</description> <display-name>this is the display name of my j2e E component</display-name> <servlet-name>StudentServlet</servlet-name> <servlet-class> Pers.ms.rfeng.servlet.studentservlet</servlet-class> </servlet> <servlet-mapping> < Servlet-name>studentservlet</servlet-name> <url-pattern>/StudentServlet</url-pattern> </ Servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> < Welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcoMe-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</ Welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list></web-app>

//////////////////

The font is small, CTRL + You can resize the interface, the corresponding ctrl-

The effect is as shown at the beginning.

Detailed page style, like content centered. Color, add some of your own style. Be able to write the corresponding changes in the corresponding JSP



Java Web page Paging implementation

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.