在服务端查询一个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都不行,有路过的大神可以指点一二。