当前位置: 代码迷 >> Java Web开发 >> 在线急等,求一段jsp+javabean的分页代码,该如何解决
  详细解决方案

在线急等,求一段jsp+javabean的分页代码,该如何解决

热度:103   发布时间:2016-04-17 14:01:37.0
在线急等,求一段jsp+javabean的分页代码
最近在做作业.是一个新闻管理系统遇到了一个分页难题,
这是在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 ")%> &nbsp; </a> </div> </td>
  相关解决方案