jsp页面调用服务器端接口分页显示数据的问题

index.jsp页面:


<li><a href="youhui/youhuiindex.jsp?page=1 "><img src="images/youhuiquan.png"></img><br/></a>优惠券</li>


youhuiindex.jsp页面:


<%@ page language="java" import="java.util.*,java.lang.* " pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql_rt" %>
<%@taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>


<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
Integer ssh=Integer.parseInt(request.getParameter("page"))+1;
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
   
    <title>My JSP 'youhuiindex.jsp' starting page</title>
   
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">   
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <link rel="stylesheet" type="text/css" href="css/bijia/bijiaindex.css">
<script type='text/javascript' src='js/jquery-latest.js'></script>
<script type="text/javascript">
var murl='http://192.168.1.122:8080/bjmobile/viewCoupons.do';
var page='<%=request.getParameter("page")%>';
//alert(page);
//page=1+parseInt(page);
murl=murl+'?page='+page;
$(function() {
     var items='';
     $.post(murl,function(data){
         var json=eval("(" + data + ")");
         //alert(data);
         //alert(json["couponList"][0].title);
         //alert(json.length);
         for(var i=0;i<json["couponList"].length;i++){
             items=items+'<a href="#" style="text-decoration: none"><div class="item1">['+json["couponList"][i].stronename+']'+json["couponList"][i].titile+'    > </div></a>';
         }
         $("#item").html(items);           
     });
});
</script>

  </head>
 
  <body>
    <div class="head1">
    <input class="loc1" type="submit" value="返回" οnclick="javascript:window.location.href='index.jsp'">
    <font class="loc2">优惠券</font>
    </div>
    <div id="item"></div>
    <hr/>
    <div><a href="youhui/youhuiindex.jsp?page=
<c:out value='<%=(ssh)%>'/> ">下一页</a> 第 <%=(ssh-1)%> 页</div>
  </body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
package com; public class Pager { private int totalRows = 0; // 记录总数 private int totalPages = 0; // 总页数 private int pageSize = 10; // 每页显示数据条数,默认为10条记录 private int currentPage = 1; // 当前页数 private boolean hasPrevious = false; // 是否有上一页 private boolean hasNext = false; // 是否有下一页 public int getSearchFrom() { return (currentPage - 1) * pageSize; } public Pager() { } public void init(int totalRows) { this.totalRows = totalRows; this.totalPages = ((totalRows + pageSize) - 1) / pageSize; refresh(); // 刷新当前页面信息 } /** * * @return Returns the currentPage. * */ public int getCurrentPage() { return currentPage; } /** * * @param currentPage * current page * */ public void setCurrentPage(int currentPage) { this.currentPage = currentPage; refresh(); } /** * * @return Returns the pageSize. * */ public int getPageSize() { return pageSize; } /** * * @param pageSize * The pageSize to set. * */ public void setPageSize(int pageSize) { this.pageSize = pageSize; refresh(); } /** * * @return Returns the totalPages. * */ public int getTotalPages() { return totalPages; } /** * * @param totalPages * The totalPages to set. * */ public void setTotalPages(int totalPages) { this.totalPages = totalPages; refresh(); } /** * * @return Returns the totalRows. * */ public int getTotalRows() { return totalRows; } /** * * @param totalRows * The totalRows to set. * */ public void setTotalRows(int totalRows) { this.totalRows = totalRows; refresh(); } // 跳到第一页 public void first() { currentPage = 1; this.setHasPrevious(false); refresh(); } // 取得上一页(重新设定当前页面即可) public void previous() { if (currentPage > 1) { currentPage--; } refresh(); } // 取得下一页 public void next() { //System.out.println("next: totalPages: "

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值