欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JS組件Bootstrap Table使用實(shí)例分享

 更新時(shí)間:2016年05月30日 09:37:39   作者:xdw1516  
這篇文章主要為大家詳細(xì)介紹了JS組件Bootstrap Table分頁(yè)使用方法,具有一定的實(shí)用性,感興趣的小伙伴們可以參考一下

學(xué)習(xí)使用bootstrap表格是對(duì)客戶端進(jìn)行分頁(yè)的時(shí)候,在朋友的幫助下,找到了文檔http://bootstrap-table.wenzhixin.net.cn/examples/                 
找到了傳到后臺(tái)的每頁(yè)條數(shù)Limit,和記錄開始數(shù)Offset。             
開始封裝,分享一下我的代碼,從bootstrap table 獲取頁(yè)碼和頁(yè)數(shù),并交給后臺(tái)處理。

$('#table').bootstrapTable({
  url: '<%=path%>/FeedList.cqzk',
  striped: true,
  pagination: true,
  pageList: [3,5,20],
  pageSize:3,
  pageNumber:1,
  sidePagination:'server',//設(shè)置為服務(wù)器端分頁(yè)
  columns: [{
  field: 'title',
  title: '標(biāo)題'
  }, {
  field: 'creatTime',
  title: '時(shí)間'
  } ]
 });



 @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) 就多一個(gè)中括號(hào),返回的就是數(shù)組,寫了就是返回第一個(gè)對(duì)象。
 }
 


public BootPage getByPage(String hql,BootPage pager,Map<String, Object> condition){
 if (pager == null) {
  throw new IllegalArgumentException("分頁(yè) 不能為空!");
 }

 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" ;

如果大家還想深入學(xué)習(xí),可以點(diǎn)擊這里進(jìn)行學(xué)習(xí),再為大家附3個(gè)精彩的專題:

Bootstrap學(xué)習(xí)教程

Bootstrap實(shí)戰(zhàn)教程

Bootstrap插件使用教程

以上就是為大家分享的Bootstrap Table使用方法,希望對(duì)大家熟練掌握Bootstrap Table使用方法有所幫助。

相關(guān)文章

最新評(píng)論