前面有GET方式的笔记:Android下处理xml数据,POST的方式可能有点不一样:

URL url = new URL( SERVER_URL );
HttpURLConnection conn;
conn = (HttpURLConnection) url.openConnection();
//这个要打开
conn.setDoOutput(true);
conn.setDoInput(true);

//处理POST的数据
conn.setRequestMethod("POST");
String username="action=mylist&myUid=Something";
conn.getOutputStream().write(username.getBytes());
conn.getOutputStream().flush();
conn.getOutputStream().close();

InputStream is = conn.getInputStream();

//下同...


参考:使用HttpURLConnection进行POST方式提交,还可以设置请求的头信息
这里也有POST的方法:android文件上传到服务器


原创内容如转载请注明:来自 阿权的书房
收藏本文到网摘
Tags:
发表评论
表情
emotemotemotemotemotemotemotemotemotemotemotemotemot
emotemotemotemotemotemotemotemotemotemotemotemot
打开HTML 打开UBB 打开表情 隐藏
昵称   密码   游客无需密码
网址   电邮   [注册]
               

验证码 不区分大小写
 

阅读推荐

服务器相关推荐

开发相关推荐

应用软件推荐