经典翻页之当前页码居中

阅读更多
package com.surfilter.datacenterweb.util.page;

import com.surfilter.datacenterweb.bean.DataCenterParam;
import com.surfilter.datacenterweb.util.ContextUtil;

public class SutraPage {

	private static DataCenterParam dataCenterParam = (DataCenterParam) ContextUtil
			.getBean("dataCenterParam");

	/**
	 * 分页使用工具方法
	 * @param pageNo
	 * @param pages
	 * @return
	 */
	public static String formatPage(Integer pageNo, Integer pages) {
		String urlstart = "上一页  ");
		}
		for (int i = start; i < pageNo; i++) {
			buffer.append(urlstart + i + ">[" + i + "]  ");
		}
		buffer.append(" " + pageNo + "   ");
		for (int i = pageNo + 1; i <= end; i++) {
			buffer.append(urlstart + i + ">[" + i + "]  ");
		}
		if (pageNo != pages) {
			buffer.append(urlstart + (pageNo + 1) + ">下一页  ");
		}
		return buffer.toString();
	}
	
	public static void main(String[] args) {
		System.out.println(SutraPage.formatPage(5, 23));
	}

	/**
	 * 首次查询分页显示工具方法
	 * @param pages
	 * @return
	 */
	public static String formatPage(Integer pages) {
		StringBuffer buffer = new StringBuffer();
		buffer.append("  " + 1 + "  ");
		for (int i = 2; i <= (pages > 10 ? 10 : pages); i++) {
			buffer.append("[" + i
					+ "]    ");
		}
		if (pages > 10) {
			buffer.append("下一页  ");
		}
		return buffer.toString();
	}

}

 

//简单点出分页页码算法. 

你可能感兴趣的:(j2ee,code)