爱问知识人 爱问教育 医院库

如何在JSP页面中实现检索数据的分页显?

首页

如何在JSP页面中实现检索数据的分页显?

如何在JSP页面中实现检索数据的分页显示

提交回答

全部答案

    2018-03-31 05:15:34
  •   下面将通过一些例程来说明实现JSP页面翻页技术的实现。首先,在JSP中,通过JAVA servlet 来检索数据,而用JSP来调用结果来显示。 因而,此技术可分为两个部分(依赖关系): 1。 在服务器端的servlet 中的实现 要点: 1)将查询条件保存到session中,取session中的查询条件 2)设置Statement对象的MaxRows(确定一页显示多少行数据) 3)顺序地通过执行SQL语句查询数据,按maxRows 来检索一个maxRows的数据, 下一页再检索下一maxRows的数据,以此类推。
       2。 在JSP中的显示实现 要点: 1)显示maxRows条数据 2)通过“下一页”按钮或超链再次调用刚才的servlet查询下一maxRows的数据 流程如图所示: 下面通过一个例程来说明(一个servlet程序和一个JSP程序): l querymedicine。
       java (Medicine。 querymedicine) package Medicine; import javax。servlet。*; import javax。servlet。http。*; import java。io。*; import java。
      util。*; import java。sql。*; import Medicine。medicinelist; import Medicine。searchData; //////////////////////////////////////////////////// // 接---mutiquery。
      jsp页面,并从request中得到5条查询条件 /// // 按条件查询药品,并将结果存进session的“medicinelist”中。 /// //////////////////////////////////////////////////// public class querymedicine extends HttpServlet { private DBConnectionManager connMgr; //Initialize global variables public void init(ServletConfig config) throws ServletException { super。
      init(config); connMgr = DBConnectionManager。getInstance(); } //========================处理 HTTP Get 请求============================ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Statement stmt=null; Connection con = connMgr。
      getConnection("medicine"); if (con == null) { response。sendRedirect("/medicine/con_error。html"); return; } // ==================== 创建数据库Statement ============================= try { stmt=con。
      createStatement(); } catch (Exception e) { connMgr。freeConnection("medicine",con); response。sendRedirect("/medicine/stmt_error。
      html"); return; } //------------------------------------------------------------- long all_count=0; //存满足条件的药品总数 //===================从request中得到session====================== try{ HttpSession session = request。
      getSession(false); if (session == null) { connMgr。freeConnection("medicine",con); response。sendRedirect("/medicine/session_error。
      html"); return; } //----------------------------------------------------------- //======从“下一页”提交来的参数取得前页最后一条数据的药品编码======= String ll_pos=request。
      getParameter("pos"); //如果pos=-1则表示要从头开始查 //----------------------------------------------------------。

    赵***

    2018-03-31 05:15:34

类似问题

换一换

相关推荐

正在加载...
最新问答 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):