$("#gupiaopage").page({
showInfo: false,
showJump: false,
showPageSizes: true,
firstBtnText: '首页',
lastBtnText: '尾页',
prevBtnText: '上一页',
nextBtnText: '下一页',
jumpBtnText:'跳转',
infoFormat: '{start} ~ {end}条,共{total}条',
pageSize:20,
remote: {
pageIndexName: 'page', //请求参数,当前页数,索引从0开始
pageSizeName: 'rows', //请求参数,每页数量
url: webPath+'/attention/gupiao',
params:{
userId:'1'
},
success: function (data, pageIndex) {
//console.log(data);
var datas = data.list;
var html ;
for(var i=0;i<datas.length;i++){
//拼接html
}
$('#gupiaotable').html(html);
},
}
});
<div id="gupiaopanel" class="noshow">
<table class="guanzhutable" id="gupiaotable">
</table>
<div id="gupiaopage"></div>
</div>
后台
@RequestMapping("/gupiao")
public void pinglun(HttpServletRequest req, HttpServletResponse res) throws Exception{
String callback = req.getParameter("callback");
Map<String,Object> map = new HashMap<String,Object>();
int page = Integer.parseInt(req.getParameter("page"));
page = page+1;
PageParam pageParam = CtrlUtils.getPageParam(req);
pageParam.setStart((page-1)*pageParam.getLimit());
String userId = UtilsSession.getUserId(req.getSession());
Page<UserAttentionStock> ret = userAttentionStockService.queryPageByUserId(userId, pageParam); List<UserAttentionStock> dataList = ret.getDatas();
for (UserAttentionStock uas : dataList) {
uas.setUser(null);
}
map.put("total", ret.getTotalProperty());
map.put("list", dataList);
CtrlUtils.putJsonp(callback,map, res);
}