本文转载自:
https://www.cnblogs.com/panxuejun/p/6148592.html 作者:panxuejun 转载请注明该声明。
//确保JSP和servlet的编码方式一致 resp.setContentType("text/html;charset=GBK"); List<String> jymdList = new ArrayList<String>(); PrintWriter out = null; try { //从数据库中取得List jymdList = efileViewUiService.getLymd(); //简单粗暴,对于Map这句也适用 String json = JSON.toJSONString(jymdList); //取得流向JSP传递数据 PrintWriter out = resp.getWriter(); out.print(json); } catch (BaseException e) { e.printStackTrace(); } finally{ out.close(); } 复制代码