freemarker自定义分页标签宏

用法:
<#include "/common/pager.html"> 
<@pager pager=param baseUrl="${basePath}/admin/pageList" parameterMap=parameterMap />
 
需要业务对象继承下面的实体:
public class Pager {
/** 
* 当前页码 
*/ 
private int pageIndex = 1; 
/** 
* 每页显示多少个 
*/ 
private int pageSize = 10; 
/** 
* 多少页 
*/ 
private int totalPage;
    
    
	public int getPageIndex() {
		return pageIndex;
	}
	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
}
  
查询调用方式:
4. 查询调用方式
ExampleQueryBean exampleQueryBean = new ExampleQueryBean(); 
exampleQueryBean.setTotalPage(2); 
exampleQueryBean.setPageIndex(2); 
exampleQueryBean.setPageSize(10); 

model.addAttribute("param", exampleQueryBean); 

Map<String,String> parameterMap = new HashMap<String,String>(); 
parameterMap.put("supplierId", "100"); 
parameterMap.put("supplierName", "丽都饭店"); 

model.addAttribute("parameterMap", parameterMap);
 
 

相关推荐