layui表格 返回的数据状态异常的解决方法
最近用到了layui表格组件,结果发现数据返回状态异常在网上查询了下是因为需要转成固定个格式
然而layui的table默认返回的数据格式为:
response:{//定义后端json格式,详细参见官方文档 code:0, msg:"", count:1000, data:[] }
网上看了有些方法是转成json数据
JSONObjectobj=newJSONObject(); //前台通过key值获得对应的value值 obj.put("code",0); obj.put("msg",""); obj.put("count",1000); obj.put("data",list); //array.add(obj); returnobj.toString();
感觉有点麻烦
publicMapqueryUserList(Integercurr,Integerlimit){ PageHelper.startPage(Integer.valueOf(curr),Integer.valueOf(limit)); List list=loginMapper.queryUserList(); longtotal=((Page)list).getTotal(); Map map=newHashMap<>(); map.put("code",0); map.put("msg",""); map.put("count",total); map.put("data",list); returnmap; }
感觉还是用这个HashMap集合感觉方便一点顺便分页功能也实现了!!
以上这篇layui表格返回的数据状态异常的解决方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。