mysql 自定义分页_自定义分页标签结合spring mvc、bootstrap、mybatis、mysql的使用

35d184055f68f18ff85280fd7e2a0fa1.png

pager.tld

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"

version="2.0">

Pager

1.0

page

createPager

com.test.utils.Pager

JSP

curPage

true

true

java.lang.Integer

totalPage

true

true

java.lang.Integer

pageSize

true

true

java.lang.Integer

totalCount

true

true

java.lang.Integer

formId

true

true

java.lang.String

Pager.java

import java.io.IOException;

import javax.servlet.jsp.JspException;

import javax.servlet.jsp.JspWriter;

import javax.servlet.jsp.tagext.TagSupport;

/***

* 分页控件

* @author 花非花雾非雾

*/

public class Pager extends TagSupport {

private static final long serialVersionUID = 1L;

private Integer curPage;

private Integer totalPage;

private Integer pageSize = TestConstance.pageSize;

private Integer totalCount = 0;

private String formId;

public void setCurPage(Integer curPage) {

this.curPage = curPage;

}

public void setPageSize(Integer pageSize) {

this.pageSize = pageSize;

}

public void setTotalPage(Integer totalPage) {

this.totalPage = totalPage;

}

public void setFormId(String formId) {

this.formId = formId;

}

public Integer getTotalCount() {

return totalCount;

}

public void setTotalCount(Integer totalCount) {

this.totalCount = totalCount;

}

public int doStartTag() throws JspException {

JspWriter out = pageContext.getOut();

int pageNumber = 0;

if (totalPage%pageSize==0) {

pageNumber = totalPage/pageSize;

} else {

pageNumber = (totalPage/pageSize)+1;

}

if (curPage < 1) {

curPage = 1;

}

try {

if (pageNumber > 0) {

out.print("

"function go(pageNum){" +

"var f = document.getElementById('" + formId + "');"+

"f.action = f.action + '?pageNum=' + pageNum + '&pageSize="+pageSize+"';"+

"f.submit();"+

"}" +

"");

out.print("

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值