服务端返回List<Map<String,Object>>数据,$http 无法接收
2017-10-25 11:09
766 查看
在服务端查询一个list<Map<String,Object>> 类型的数据,返回前端,但是一直报错[ERROR] : TypeError: b.apply is not a function,类型错误,然后查了很多有关list和json相互转换的资料,试了网上查到很多方法,依然无法解决这个问题。。。。
最后在同事的帮助下,找到了这个问题的解决方法,我只简单的写一下重点,本方法写在服务端
* @param request
* @param response
* @return
* @throws IOException
*/
@RequestMapping(value = "/oachklist/{usercode}", method = { RequestMethod.POST, RequestMethod.GET })
public void getCheckDetailList(HttpServletRequest request, HttpServletResponse response, @PathVariable("usercode") String usercode) throws IOException
{
//自己的逻辑处理程序,得到一个list<Map<String,Object>>类型的数据
//接下来就是见证奇迹的时刻
PrintWriter out = response.getWriter();
net.sf.json.JSONObject json=new new JSONObject();
json.put("result", list);
try{
out.print(json.toString());
}catch(Exception e)
{
e.printStackTrace();
}finally{
out.close();
}
}
处理程序大致就是这样,但是还不懂为什么把list放进json里面返回或者转换成jsonarray都不行,有路过的大神可以指点一二。
最后在同事的帮助下,找到了这个问题的解决方法,我只简单的写一下重点,本方法写在服务端
* @param request
* @param response
* @return
* @throws IOException
*/
@RequestMapping(value = "/oachklist/{usercode}", method = { RequestMethod.POST, RequestMethod.GET })
public void getCheckDetailList(HttpServletRequest request, HttpServletResponse response, @PathVariable("usercode") String usercode) throws IOException
{
//自己的逻辑处理程序,得到一个list<Map<String,Object>>类型的数据
//接下来就是见证奇迹的时刻
PrintWriter out = response.getWriter();
net.sf.json.JSONObject json=new new JSONObject();
json.put("result", list);
try{
out.print(json.toString());
}catch(Exception e)
{
e.printStackTrace();
}finally{
out.close();
}
}
处理程序大致就是这样,但是还不懂为什么把list放进json里面返回或者转换成jsonarray都不行,有路过的大神可以指点一二。
相关文章推荐
- Mybatis查询表数据及其列名,返回List<Map<String,Object>>
- List<Map<String, Object>> 转换成JSON数据格式保存再转List<Map<String, Object>> 返回
- List<Map<String, Object>>保存的是引用数据类型的地址
- 数据库查询返回List<Map<String, Object>>
- Android中List与Map<String,Object>及SimpleAdapter用来存储数据并展示出来的联合用法
- 行专列,拆分json,实现数据的展示。Map<String, Object>存储多个相同的key,List<Map<String, Object>>
- Mongo的morphia读取Map<String, List<Object>>类型数据的问题
- Android保存List<Map<String,Object>>数据到SD卡及读取
- mybatis返回List<Map<String,Object>>
- hibernate如何返回一个Map对象 以及List<Map<String, Object>>
- 原生sql返回List<Map<String, Object>> 转成model
- c标签遍历List<Map<String, Object>> 数据格式
- android sharedpreferences 保存 list<Map<String,Object>>数据
- Spring Mybatis 返回 List<String> 和List<Map<String,Object>>
- Mybatis 如何 返回 List<String> 类型 或 List<Map<String,Object>>类型
- 当需要对一个list<Map<String,Object>>中的map添加一个相同的数据是可以参考
- Spring Mybatis 返回List<Map<String,Object>>
- Android中将List<Map<String, Object>>类型数据与字符串的相互转化
- jdbc查询返回来的List<Map<String, Object>> 转换成List<Users>
- android 子线程通过bundle、handler.sendMessage(message)向主线程传输多个类型数据,包括list<Map<String,Object>>