2017-02-03 15:07
楼主好,我也用到了这个功能,以下是我的方式,不知能否解决你的需求,
```
###用于分页的搜索参数 TODO:如果是模糊查找或者区间查找该怎么做呢?
#sql("paginateQuery")
#setLocal(paraCount = 0)
#for(para : paraMap)
#if(para.value[0])
#if(paraCount == 0)
#setLocal(paraCount = 1)
where #(para.key) = "#(para.value[0])"
#else
and #(para.key) = "#(para.value[0])"
#end
#end
#else
where 1
#end
#end
//在控制器中先获取到查询参数
Map paraMap = getParaMap();
//在模型中调用分页
JMap queryPara = JMap.create("paraMap", paraMap);
String queryParaStr = getSql("paginateQuery", queryPara);
return paginate(pageNumber, pageSize, "select *", "from user "+queryParaStr+" order by id asc");
```