5.13-jsp分页功能实现
1、分页共能的实现
可以在dao层中创建方法 List<Member> pager(Long pageSize, Long pageNum);(方法灵活运用)
其中传入的两个参数pageSize为一页可以看多少行数据,pageNum为看第几页
而startIndex则应该为startIndex=(pageNum-1)*pageSize
————————————————
版权声明:本文为CSDN博主「会微笑的桃子」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_42979840/article/details/82988702
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<jsp:include page="/index_head.jsp">
<jsp:param name="title" value="个人主页" />
</jsp:include>
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>
个人名片 <small>different form elements</small>
</h2>
<div class="clearfix"></div>
</div>
<div class="x_content">
<div class="col-md-3 col-sm-3 col-xs-12 profile_left">
<div class="profile_img">
<div id="crop-avatar">
<img class="img-responsive avatar-view"
src="${pageContext.request.contextPath}/statics/images/<c:if test="${empty user.head_img}">img.jpg</c:if><c:if test="${not empty user.head_img}">user/${user.head_img}</c:if>"
alt="${user.nick_name}" title="${user.nick_name}">
</div>
</div>
<h3>${user.nick_name}</h3>
<ul class="list-unstyled user_data">
<li><span class="fa fa-envelope user-profile-icon"
aria-hidden="true"></span> ${user.login_mail}</li>
<li><i class="fa fa-user user-profile-icon"></i>
${user.true_name}</li>
<li><i class="fa fa-intersex user-profile-icon"></i>
${user.sex}</li>
<li><i class="fa fa-phone user-profile-icon"></i>
${user.phone}</li>
<li><i class="fa fa-credit-card "></i> ${user.id_card}</li>
<li><i class="fa fa-at user-profile-icon"></i> ${user.qq_code}</li>
<li><i class="fa fa-commenting-o user-profile-icon"></i>
${user.wechat_code}</li>
<li><i class="fa fa-tags user-profile-icon"></i>
${user.signature}</li>
</ul>
<c:if test="${empty requestScope.user}">
<a
href="${pageContext.request.contextPath}/user/edit?action=change"
class="btn btn-success"><i class="fa fa-edit m-right-xs"></i>编辑资料</a>
</c:if>
<br>
</div>
<div class="col-md-9 col-sm-9 col-xs-12">
<div role="tabpanel" data-example-id="togglable-tabs">
<ul id="myTab" class="nav nav-tabs bar_tabs" role="tablist">
<c:if test="${user.user_type==2}">
<li role="presentation" class="active"><a
href="#tab_content1" id="home-tab" role="tab" data-toggle="tab"
aria-expanded="true">创建的社团</a></li>
</c:if>
<li role="presentation" class=""><a href="#tab_content2"
role="tab" id="profile-tab" data-toggle="tab"
aria-expanded="false">加入的社团</a></li>
</ul>
<div id="myTabContent" class="tab-content">
<c:if test="${user.user_type==2}">
<div role="tabpanel" class="tab-pane fade active in"
id="tab_content1" aria-labelledby="home-tab">
<ul class="list-unstyled user_data">
<c:forEach items="${clublist}" var="club">
<li><a
href="${pageContext.request.contextPath}/club/lookclub?name=${club.name}&id=${club.id}"
class="user-profile dropdown-toggle"> <img
src="${pageContext.request.contextPath}/statics/images/club/${club.id}.jpg">
${club.name}
</a></li>
</c:forEach>
</ul>
<c:if test="${user.club_count!=5}">
<a class="btn btn-primary"
href="${pageContext.request.contextPath}/club/add">创建社团</a>
</c:if>
</div>
</c:if>
<c:if test="${user.club_count==0}">
<div role="tabpanel" class="tab-pane fade" id="tab_content2"
aria-labelledby="profile-tab">还没有加入社团,快去加入吧</div>
</c:if>
<c:if test="${user.club_count!=0}">
<div role="tabpanel" class="tab-pane fade" id="tab_content2"
aria-labelledby="profile-tab" style="height: 320px;">
<div style="height: 320px;">
<ul class="list-unstyled user_data" id="ul">
</ul>
</div>
<ul class="nav nav-pills"
style="margin-left: 720px; display: none;" id="page">
<li class="active" id="prev"><a href="" data-toggle="tab"
onclick="prev()">上一页</a></li>
<li style="margin-left: 10px;" id="next"><a href=""
data-toggle="tab" onclick="next()">下一页</a></li>
</ul>
</div>
</c:if>
</div>
</div>
</div>
</div>
</div>
</div>
<jsp:include page="/index_foot.jsp"></jsp:include>
<script type="text/javascript">
var page=1;
var l=1;
var pa;
$(function() {
$("#prev").attr("style","visibility:hidden");
$.ajax({
url : "${pageContext.request.contextPath}/club/page",
data : "page=1&id="+${user.id},
type : "get",
success : function(data) {
$.each(data,function(){
var li=$("<li style='float: left; margin-right: 35px; width: 140px; margin-bottom: 50px;'></li>");
var a=$("<a class='user-profile dropdown-toggle'></a>").attr("href","${pageContext.request.contextPath}/club/lookclub?name="+this.name+"&id="+this.id);
var img=$("<img>").attr("src","${pageContext.request.contextPath}/statics/images/club/"+this.logo);
$("#ul").append(li.append(a.append(img).append(this.name)));
})
}
})
})
var clubs = ${clublist};
if(clubs.length > 1){
$("#page").show();
}
function prev() {
$("#next").attr("style","visibility:visible");
page--;
if(page==1){
$("#prev").attr("style","visibility:hidden");
}
$.ajax({
url : "${pageContext.request.contextPath}/club/page",
data : "page=" + page+"&id="+${user.id},
type : "get",
success : function(data) {
l-=pa;
pa=data.length;
$("#ul").empty();
$.each(data,function(){
var li=$("<li style='float: left; margin-right: 35px; width: 140px; margin-bottom: 50px;'></li>");
var a=$("<a class='user-profile dropdown-toggle'></a>").attr("href","${pageContext.request.contextPath}/club/lookclub?name="+this.name+"&id="+this.id);
var img=$("<img>").attr("src","${pageContext.request.contextPath}/statics/images/club/"+this.logo);
$("#ul").append(li.append(a.append(img).append(this.name)));
})
}
})
}
function next() {
page++;
$("#prev").attr("style","visibility:visible");
$.ajax({
url : "${pageContext.request.contextPath}/club/page",
data : "page=" + page+"&id="+${user.id},
type : "get",
success : function(data) {
pa=data.length;
l+=data.length;
if(l==clubs.length){
$("#next").attr("style","visibility:hidden");
}
$("#ul").empty();
$.each(data,function(){
var li=$("<li style='float: left; margin-right: 35px; width: 140px; margin-bottom: 50px;'></li>");
var a=$("<a class='user-profile dropdown-toggle'></a>").attr("href","${pageContext.request.contextPath}/club/lookclub?name="+this.name+"&id="+this.id);
var img=$("<img>").attr("src","${pageContext.request.contextPath}/statics/images/club/"+this.logo);
$("#ul").append(li.append(a.append(img).append(this.name)));
})
}
})
}
</script>
5.13-jsp分页功能实现的更多相关文章
- jsp分页功能
http://blog.csdn.net/xiazdong/article/details/6857515
- jsp、js分页功能的简单总结
一.概述 首先,我们要明确为何需要分页技术,主要原因有以下: 1.分页可以提高客户体验度,适当地选择合适的数据条数,让页面显得更有条理,使得用户体验感良好,避免过多数据的冗余. 2.提高性能的需要.分 ...
- 分页功能的实现——Jdbc && JSP
@目录 什么是分页 ? 两个子模块功能的问题分析 和 解决方案 有条件查和无条件查询的影响 和 解决方案 项目案例: mysql + commons-dbutils+itcast-tools+Base ...
- WinForm DataGridView分页功能
WinForm 里面的DataGridView不像WebForm里面的GridView那样有自带的分页功能,需要自己写代码来实现分页,效果如下图: 分页控件 .CS: 1 using System; ...
- Net 分页功能的实现
首先写一个接口 1 2 3 4 5 6 public interface IPagedList { int CurrentPageIndex { get; set; } ...
- 自己封装的JS分页功能[用于搭配后台使用]
* 2016.7.03 修复bug,优化代码逻辑 * 2016.5.25 修复如果找不到目标对象的错误抛出. * 2016.5.11 修复当实际页数(pageNumber)小于生成的页码间隔数时的bu ...
- 【jQuery 分页】jQuery分页功能的实现
自写的jQuery实现分页功能的分页组件: 功能效果如下: 分页组件就是上图中的三部分, 分别放在表格上部 和下部 . 其中, 1>>>页面的代码如下: product.jsp 其 ...
- 夺命雷公狗---DEDECMS----33dedecms自定义搜索以及分页功能完成
我们现在要开始实现模版里面的搜索功能了,我们先找要做出一个检索提交表单,如下所示: 只要我们点击生成之后我们的表单就获取到了,可以直接拿生成好的html表单拿来用来测试下.. 将他嵌入首页的模版文件, ...
- python_way day18 html-day4, Django路由,(正则匹配页码,包含自开发分页功能), 模板, Model(jDango-ORM) : SQLite,数据库时间字段插入的方法
python_way day18 html-day4 1.Django-路由系统 - 自开发分页功能 2.模板语言:之母板的使用 3.SQLite:model(jDango-ORM) 数据库时间字 ...
- aspnetpager+repeater+oracle实现分页功能
一.设计原理阐述 数据查询分页,这个功能相信大家都很熟悉,通过数据库或其它数据源进行查询操作后,将获得的数据显示到界面上,但是由于数据量太大,不能一次性完全的显示出来,就有了数据分页的需求.这个需求在 ...
随机推荐
- Mysql中不能update自身的解决方法
不能执行:update bi_data.order_all_detailset err_msg='同时存在于wx,zfb平台',proc_time=now()where order_no in( se ...
- JAVA从字符串中提取纯数字
/** * 从字符串中提取纯数字 * @param str * @return */ public static String getNumeric(String str) { String regE ...
- js-fn函数返回一个引用变量的细节
1.直接返回一个字面量对象 function fun1() { return { age:10, name:'adain' } a = fun1(); b = fun1(); b.age = 18 ; ...
- BERT生成能力改进:分离对话生成和对话理解
NLP论文解读 原创•作者 | 吴雪梦Shinemon 研究方向 | 计算机视觉 导读说明: NLP任务大致可以分为NLU(自然语言理解)和NLG(自然语言生成)两种,NLU负责根据上下文去理解当前用 ...
- FilesCodingConvert--批量文件编码格式转换工具
FilesCodingConvert–批量文件编码格式转换工具 简介 最近开始学习使用Android Studio,因为它的方便易用,我打算以后就不在使用ADT的方式编写Android项目了.当从Ec ...
- 【九度OJ】题目1475:IP数据包解析 解题报告
[九度OJ]题目1475:IP数据包解析 解题报告 标签(空格分隔): 九度OJ http://ac.jobdu.com/problem.php?pid=1475 题目描述: 我们都学习过计算机网络, ...
- 【LeetCode】72. Edit Distance 编辑距离(Python & C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 递归 记忆化搜索 动态规划 日期 题目地址:http ...
- 【LeetCode】594. Longest Harmonious Subsequence 解题报告(Python & C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 统计次数 日期 题目地址:https://leetc ...
- leetcode1261在受污染的二叉树中查找元素
题目 一颗二叉树,树根值为0,父节点为x,则左子值为2x+1,右子为2x+2.现在只有树的结构,所有值都变为-1被污染了.求污染前是否存在某个值. 构建一次树,查询会调用多次. 题解 这道题还是比较简 ...
- 【LeetCode】831. Masking Personal Information 解题报告(Python)
[LeetCode]831. Masking Personal Information 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzh ...