WEB programming page shows stray kid
As the saying goes, "Ten is the beginning is difficult", it is true that the beginner Web programming has always had a lot of questions. Here, the following is a relatively common problem - page display. There are many articles that are paged online, but most of them are implemented with ASP, this program implements paging display in JSP. The idea of the program is to calculate the total number of pages by obtaining the total number of OTALs, and the records that are displayed in each page. The read of the specified data is then implemented by controlling the movement of the pointer. The following is interpreted by the program example. First, create a data sheet and wait for a call. (Because only experiments are only used as a database), a database table named TEST is created. For the simple field, as long as three, it is ID (Auto Number), Name (Text), Passowrd (Text). Then insert some data to the database. Note The database is to establish a system DSN in the ODBC Data Source Manager.
<% //Written by qiyadeng; //pages.jsp%> <% @ page contenttype = "text / html; charset = GB2312"%> <% @ page import = "java.sql. *"%>
Rs.last (); // Move to the last record; Total = rs.getrow (); // Total number of records; // calculate the total number of pages TotalPage; if (Total% Everypage == 0) Totalpage = Total / Everypage; elseTotalPage = Total / Everypage 1; // Get the value of the text box input; string pages = request.getParameter ("pages"); if (pages! = Null) {onpage = integer.parseint (PAGES); / / Convert the PAGES to an integer; / / Depending on the value of the input, it is determined that the page that should be displayed; if (onpage> TotalPage;} else if (onpage <= 0) {onpage = 1;}}} Absolute 1); / / Specify the position of the pointer;%>
User No. TD> | User Name TD> | Password TD> TR> <% // Recording displayed; for (int i = 1; i <= everypage; i ) {%> |
<% = = r .getstring ("id")%> td> | <% = rs.getstring ("name")%> td> | <% = rs.getstring ("password")%> < /t> %%% (退 退;;;;;;;;;;;;;;;;; () .Close ();%> table> center> <% // is currently displaying something to display; if (onpage! = 1) {%>
转载请注明原文地址:https://www.9cbs.com/read-11696.html New Post(0)
|