后端获取ip地址的Java,分页的基本类Java

1.后端获取ip地址的Java方法:

String clientIp = request.getHeader("x-forwarded-for");
        if(clientIp == null || clientIp.length() == 0 || "unknown".equalsIgnoreCase(clientIp)) {
            clientIp = request.getHeader("Proxy-Client-IP");
        }
        if(clientIp == null || clientIp.length() == 0 || "unknown".equalsIgnoreCase(clientIp)) {
            clientIp = request.getHeader("WL-Proxy-Client-IP");
        }
        if(clientIp == null || clientIp.length() == 0 || "unknown".equalsIgnoreCase(clientIp)) {
            clientIp = request.getRemoteAddr();
        }

2.分页的基本类

package com.kd.nm.util;

/**
 * 页面设置
 * @author 25338
 * @date 2019-12-3
 */
public class PageUtil {
	private Integer currentPage;//当前页
	private Integer counts;//总数量
	private Integer pageSize;//总页数
	private Integer pageCounts;//页容量
	private Integer startSuffix;//开始下标
	
	/**
	 * 页码
	 * @param currentPage 当前页
	 * @param counts 总数量
	 * @param pageCounts 页容量
	 */
	public PageUtil(Integer currentPage, Integer counts, Integer pageCounts) {
		this.currentPage = currentPage;
		this.counts = counts;
		this.pageCounts = pageCounts;
		this.pageSize=counts%pageCounts==0?counts/pageCounts:counts/pageCounts+1;
		this.startSuffix=(currentPage-1)*pageCounts;
	}
	/**
	 * 初始化进入时
	 * @param pageCount
	 */
	public PageUtil(Integer pageCount) {
		this.startSuffix=0;
		this.pageCounts=pageCount;
	}
	
	
	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getStartSuffix() {
		if(startSuffix==null||startSuffix==0) {
			return 1;
		}
		return startSuffix;
	}

	public void setStartSuffix(Integer startSuffix) {
		this.startSuffix = startSuffix;
	}

	public Integer getCurrentPage() {
		if(currentPage==null||currentPage==0) {
			return 1;
		}
		return currentPage;
	}
	public void setCurrentPage(Integer currentPage) {
		this.currentPage = currentPage;
	}
	public Integer getCounts() {
		return counts;
	}
	public void setCounts(Integer counts) {
		this.counts = counts;
	}
	public Integer getPageCounts() {
		return pageCounts;
	}
	public void setPageCounts(Integer pageCounts) {
		this.pageCounts = pageCounts;
	}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值