在服務端查詢一個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都不行,有路過的大神可以指點一二。