1.Without server-side pagination

data-side-pagination="client"(bs-table的设置)

服务器端代码:

@RequestMapping(value ="/toUserList")
@ResponseBody
public JSONArray toWebapp(String name,String password) {

List<UserInfo> userList = new ArrayList<>();
UserInfo userInfo = new UserInfo((long)1,"wl","123");
UserInfo userInfo1 = new UserInfo((long)2,"yq","yq123");
UserInfo userInfo2 = new UserInfo((long)3,"xb","xb123");
userList.add(userInfo);
userList.add(userInfo1);
userList.add(userInfo2);
Map<String, Object> map = new HashMap<String, Object>();
if(userList != null) {
map.put("total", userList.size());
map.put("rows", userList);
}
JSONArray userList1 = JSONArray.fromObject(userList);
//JSONArray fromObject = JSONArray.fromObject(map);

System.out.println(userList1);
return userList1;
}

前段代码:

<div class="container">
<h1>getData</h1>
<div id="toolbar">
<button id="button" class="btn btn-default">getData</button>
</div>
<table id="table"
data-toggle="table"
data-toolbar="#toolbar"
data-height="460"
data-side-pagination="client"
data-pagination="true"
data-url="${pageContext.request.contextPath}/user/toUserList.do">
<thead>
<tr>
<th data-field="id">ID</th>
<th data-field="username">username</th>
<th data-field="userpwd">userpwd</th>
</tr>
</thead>
</table>
</div>

对应的json

[
{
"id": 0,
"name": "Item 0",
"price": "$0"
},
{
"id": 1,
"name": "Item 1",
"price": "$1"
},
{
"id": 2,
"name": "Item 2",
"price": "$2"
},
{
"id": 3,
"name": "Item 3",
"price": "$3"
}
]

2.With server-side pagination

对应的属性:data-side-pagination="server"

服务端代码:

@RequestMapping(value ="/toUserList")
@ResponseBody
public Map<String, Object> toWebapp(String name,String password) {

List<UserInfo> userList = new ArrayList<>();
UserInfo userInfo = new UserInfo((long)1,"wl","123");
UserInfo userInfo1 = new UserInfo((long)2,"yq","yq123");
UserInfo userInfo2 = new UserInfo((long)3,"xb","xb123");
userList.add(userInfo);
userList.add(userInfo1);
userList.add(userInfo2);
Map<String, Object> map = new HashMap<String, Object>();
if(userList != null) {
map.put("total", userList.size());
map.put("rows", userList);
}
JSONArray userList1 = JSONArray.fromObject(userList);
//JSONArray fromObject = JSONArray.fromObject(map);

System.out.println(userList1);
return map;
}

客户端代码:

<div class="container">
<h1>getData</h1>
<div id="toolbar">
<button id="button" class="btn btn-default">getData</button>
</div>
<table id="table"
data-toggle="table"
data-toolbar="#toolbar"
data-height="460"
data-side-pagination="server"
data-pagination="true"
data-url="${pageContext.request.contextPath}/user/toUserList.do">
<thead>
<tr>
<th data-field="id">ID</th>
<th data-field="username">username</th>
<th data-field="userpwd">userpwd</th>
</tr>
</thead>
</table>
</div>

对应的json

{
"total": 200,
"rows": [
{
"id": 0,
"name": "Item 0",
"price": "$0"
},
{
"id": 1,
"name": "Item 1",
"price": "$1"
},
{
"id": 2,
"name": "Item 2",
"price": "$2"
},
{
"id": 3,
"name": "Item 3",
"price": "$3"
}
]
}

问题总结:

1.查看英文文档,中午的不细致,看不出问题来。

地址:http://bootstrap-table.wenzhixin.net.cn/documentation/

2.我的错误在于:

url data-url String undefined A URL to request data from remote site. 
Note that the required server response format is different depending on whether the 'sidePagination' option is specified. See the following examples:

bootstrap-table 加载不了数据问题总结的更多相关文章

  1. django:bootstrap table加载django返回的数据

    bootstrap table加载表格数据有两类方式: 一种通过data属性的方式配置,一种是javascipt方式配置 这里看js配置方式: 1.当数据源为.json文件时 url参数写上json文 ...

  2. bootstrap table加载数据

    //html <table id="dailyDevTable"></table> //js $(function () { initTable(); }) ...

  3. [每日一题] OCP1z0-047 :2013-08-17 EXTERNAL TABLE――加载数据 ............................56

    正确答案:C 一.对答案解释: A.       TYPE:有两个选可供选择: 1.        ORACLE_LOADER:传统方式,与SQLLDR一样,参数从多,应用较多. 2.         ...

  4. hive 压缩全解读(hive表存储格式以及外部表直接加载压缩格式数据);HADOOP存储数据压缩方案对比(LZO,gz,ORC)

    数据做压缩和解压缩会增加CPU的开销,但可以最大程度的减少文件所需的磁盘空间和网络I/O的开销,所以最好对那些I/O密集型的作业使用数据压缩,cpu密集型,使用压缩反而会降低性能. 而hive中间结果 ...

  5. [原创.数据可视化系列之三]使用Ol3加载大量点数据

    不管是百度地图还是高德地图,都很难得见到在地图上加载大量点要素,比如同屏1000的,因为这样客户端性能会很低,尤其是IE系列的浏览器,简直是卡的要死.但有的时候,还真的需要,比如,我要加载全球的AQI ...

  6. jsTree 的简单用法--异步加载和刷新数据

    首先这两个文件是必须要引用的,还有就是引用 jQuery 文件就不说了: <link href="/css/plugins/jsTree/style.min.css" rel ...

  7. 使用getJSON()方法异步加载JSON格式数据

    使用getJSON()方法异步加载JSON格式数据 使用getJSON()方法可以通过Ajax异步请求的方式,获取服务器中的数组,并对获取的数据进行解析,显示在页面中,它的调用格式为: jQuery. ...

  8. 异步加载回来的数据不受JS控制了

    写成下面这种方式时,异步加载回来的数据不受JS控制 $(."orderdiv").click(function(){ $(this).find(".orderinfo&q ...

  9. echarts 图表重新加载,原来的数据依然存在图表上

    问题 在做一个全国地图上一些饼图,并且向省一级的地图钻取的时候,原来的饼图依然显示 原因 echars所有添加的图表都在一个series属性集合中,并且同一个echars对象默认是合并之前的数据的,所 ...

  10. mxnet自定义dataloader加载自己的数据

    实际上关于pytorch加载自己的数据之前有写过一篇博客,但是最近接触了mxnet,发现关于这方面的教程很少 如果要加载自己定义的数据的话,看mxnet关于mnist基本上能够推测12 看pytorc ...

随机推荐

  1. 日历js插件

    因为做了一个培训管理模块,要有一个开始与结束培训时间.时间日期如果个用户手动输入的话,即使你要求了时间格式,但是用户可能还是会输错时间格式.所以想想,还是找了一个js日历插件.下面来介绍下我自己用的一 ...

  2. 解决:Could not parse response code.Server Reply: SSH-2.0-OpenSSH_5.3

    [摘要:办理:org.apache.commons.net.MalformedServerReplyException: Could not parse response code.Server Re ...

  3. 在PHP与HTML混合输入的页面或者模板中就需要对PHP代码进行闭合

    PHP程序的时候会在文件的最后加上一个闭合标签,如下: <?phpclass MyClass{public function test(){//do something, etc.}}?> ...

  4. Java之方法重载(笔记)

    Java是根据参数类型和个数的不同实现重载. 1.当参数类型是基本类型,但不完全匹配. void test(int i) { } void test(float f) { } public stati ...

  5. HDU 2222 Keywords Search(AC自动机模版题)

    Keywords Search Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others ...

  6. mysql5.5手册读书日记(1)

    <?php //mysql语句使用技巧 /* * 我的数据库是5.5.2 * * 查询当前用户的登陆的名字 * select user(); * * 查询当前mysql服务器时间和服务器版本 * ...

  7. DropDownList 绑定DataTable并给默认值

    string sql = @"SELECT FG_Id, FG_Name, FG_Sort, FG_IsDel FROM dbo.FirstGestation";          ...

  8. WCF初识

    WCF能干什么? 在win32中,应用程序是运行在进程的线程中的,.NET出现之后,出现了AppDomain,其实就相当于在进程和线程之间又又了一层包装层,类似于子进程的概念,在一个进程或者应用程序域 ...

  9. thinkphp多语言设置

    thinkphp多语言设置有点'高大上',为什么说它有点'高大上'呢?因为本人设置了好久才弄好,而本人之所以弄了好久的原因,竟然是因为'开启语言设置必须得先开启初始化系统的行为类',所以,在这里,因为 ...

  10. jQuery源代码阅读之三——jQuery实例方法和属性

    jQuery实例方法及属性相关的代码结构如下 jQuery.fn=jQuery.prototype={ jQuery:core_version, constructor:jQuery, selecto ...