java将List集合转换成json输出

功能概述:将集合转换成json,传递到前端进行显示

List<Weather> weatherList=new ArraryList<Weather>;

String json=JSON.toJSONString(weatherList);
respone.setCharacterEncoding("utf-8");
respone.setContentType("text/html;charset=UTF-8");
PrintWriter out=response.getWriter();
out.write(json);
out.flush();
out.close();

猜你喜欢

转载自blog.csdn.net/qq_38039015/article/details/82146199