<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="errorPage.html" %> <%@ page import="java.util.*" %> <%@ page import="data.*" %> <%@ page import="java.sql.*" %> CAD CG <% dataPageBean datapagebean=new dataPageBean(); Conn conn=new Conn(); //String sql = &amp;quot;select * from news order by shijian desc&amp;quot;; ResultSet rs; String title=null; String img=null; String id=null; String content=null; String shijian=null; String abs=null; String author=null; rs=conn.executeQuery("SELECT * FROM shishengyd order by shijian desc"); // System.out.println(&amp;quot;22&amp;quot;); if(rs.next()){ title=rs.getString("title"); //System.out.println(title); img=rs.getString("img"); abs=rs.getString("content"); //System.out.println(abs); shijian=rs.getString("shijian"); author=rs.getString("author"); id=rs.getString("ID"); } %>

师生园地

<% String pages=request.getParameter("dipage"); //设定Bean的属性 rs.last(); int countRecord=rs.getRow();//得到记录的条数 int countPageRecord=5;//每页5条记录,要设置每页记录条数就更改这个变量的值 if(pages==null||(pages.trim()).length()==0) datapagebean.setAll(countRecord,countPageRecord); else { try { datapagebean.setCurrentPage(Integer.parseInt(pages)); } catch(Exception e) { out.println("参数不正确!"); } } //当前记录号 int currentRecord=(datapagebean.getCurrentPage()-1)*datapagebean.getSizePage(); if(currentRecord==0) rs.beforeFirst(); else rs.absolute(currentRecord); int i=0; while(rs.next()){ title=rs.getString("title"); shijian=rs.getString("shijian"); id=rs.getString("ID"); %>

>> ><%=title %> [<%=shijian %>]

<% i++; if(i>=datapagebean.getSizePage()) break; //当前页显示完,则退出循环 } %>
<% rs.close(); conn.close(); %>