Android中从服务器端向客户端传数据
server端:
response.setContentType("text/plain");
response.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
UserDAO userDAO = new UserDAO();
ArrayList list = userDAO.queryUser();
JSONArray array = JSONArray.fromObject(list);
out.write(array.toString());
out.flush();
out.close();
client端:
说明:在服务器端将list集合转化为JSONArray对象,以字符串的形式传到Android的客户端,再在客户端,将字符串转换为JSONArray对象,遍历JSONArray对象即可。
补充:移动开发 , Android ,