layui表格数据与后台交互(返回的数据状态异常 )

这段时间项目前端使用了layui框架,在layui的table数据展示上花了挺长的时间。记录下解决过程:

首先后台返回的数据格式必须严格遵守官方要求的JSON数据格式

http://fly.layui.com/jie/16441/

http://www.layui.com/doc/modules/table.html 官方文档

后台代码:

@RequiresPermissions("lhyw:person:getList")

@RequestMapping(value = "/getList",method = RequestMethod.GET)

public @ResponseBody Map getList(){

List bg01s = bg01Service.showAllData();

Map resultMap = new HashMap();

resultMap.put("code",0);

resultMap.put("msg","");

resultMap.put("count","1000");

resultMap.put("data",bg01s);

// String json = JSON.toJSONString(bg01s);

// String jso = "{\"code\":0,\"msg\":\"\",\"count\":"+bg01s.size()+",\"data\":"+json+"}";

return resultMap;

}

前台代码:

上一张结果图:

layui表格数据与后台交互(返回的数据状态异常 )_第1张图片

你可能感兴趣的:(layui)