怎么将安卓客户端数据传给服务器
1个回答
展开全部
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对象即可。
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对象即可。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询