$('#table').bootstrapTable({
url: '<%=path%>/FeedList.cqzk',
striped: true,
pagination: true,
pageList: [3,5,20],
pageSize:3,
pageNumber:1,
sidePagination:'server',//设置为服务器端分页
columns: [{
field: 'title',
title: '标题'
}, {
field: 'creatTime',
title: '时间'
} ]
});
@RequestMapping(value = "/FeedList.cqzk")
@ResponseBody
public String url_ad1(HttpServletRequest request,BootPage page)
throws ServletException,IOException,RuntimeException{
@SuppressWarnings("unchecked")
// List<Feedback> list = feedBackDao.find("from Feedback");
BootPage pager = feedBackDao.getByPage("from Feedback",page,null);
System.out.println((JSONArray.fromObject(pager)).getString(0).toString());
return (JSONArray.fromObject(pager)).getString(0).toString();
// 不写.getString(0) 就多一个中括号,返回的就是数组,写了就是返回第一个对象。
}
public BootPage getByPage(String hql,BootPage pager,Map<String, Object> condition){
if (pager == null) {
throw new IllegalArgumentException("分页 不能为空!");
}
Query q = sessionFactory.getCurrentSession().createQuery(hql);
q.setFirstResult(pager.getOffset());
q.setMaxResults(pager.getLimit());
if (condition != null) {
q.setProperties(condition);
}
pager.setRows(q.list());
pager.setTotal(this.countAll(hql, condition));
return pager;
}
protected Long countAll(String hql, Map<String, Object> condition) {
if (hql == null) {
return 0l;
}
String tmpHql = hql.toLowerCase();
String regex = hql.substring(0, tmpHql.indexOf("from"));
hql = hql.replaceFirst(regex, "select count(*) ");
Query q = sessionFactory.getCurrentSession().createQuery(hql);
if (condition != null) {
q.setProperties(condition);
}
return (Long) q.uniqueResult();
}
public final class BootPage<T> {
protected Long total;
protected List<T> rows;
protected int limit=0;
protected int offset = 0;
protected String order ="asc" ;
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有