最近在做作业.是一个新闻管理系统遇到了一个分页难题,
这是在javabean中定义的在页面上显示新闻标题的代码
public class UserDenglu {
public ResultSet viewmoreNews(Connection conn, HttpServletRequest request) {
ResultSet rs = null;
try {
Statement smt = conn.createStatement();
String sql = "select newsid,title,riqi from newstable where typeID=1 order by riqi desc ";
rs = smt.executeQuery(sql);
}
catch (Exception e) {
System.out.println(e.toString());
}
return rs;
}
}
请问如何在这个类里面写一段分页代码,然后在页面又怎样调用呢?麻烦高手帮忙解决,在下不胜感激,这是页面的详细代码:
<%@ page import= "java.sql.Connection "%>
<%@ page import= "com.gxjd.zhangl.ConnUtil "%>
<%@ page import= "com.gxjd.zhangl.UserDenglu "%>
<%@ page import= "java.sql.ResultSet "%>
<%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2007-6-16
Time: 12:18:19
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType= "text/html;charset=gb2312 " language= "java " %>
<%request.setCharacterEncoding( "gb2312 ");
Connection conn= ConnUtil.getuser();
UserDenglu bean=new UserDenglu();
ResultSet rs=bean.viewmoreNews(conn,request);
%>
<html>
<head> <title> Simple jsp page </title> </head>
<body>
<form name= "form1 " method= "post " action= " ">
<table width= "700 " border= "1 " align= "center " bordercolor= " " bordercolorlight= "#FFFFFF " bordercolordark= "#FF0000 " bgcolor= " ">
<tr>
<td colspan= "3 "> 国内新闻: </td>
</tr>
<%while(rs.next()){%>
<tr>
<td colspan= "3 "> <div align= "left "> <a href= "detail.jsp?newsid= <%=rs.getString( "newsid ")%> " target= "_blank "> <%=rs.getString( "title ")%> </a> </div> </td>