Android面向HTTP协议发送get请求
来源:互联网 发布:ubuntu只有客人会话 编辑:程序博客网 时间:2024/06/03 17:43
/** * 采用get请求的方式 * * @param username * @param password * @return null表示求得的路径有问题,text返回请求得到的数据 */public static String getRequest(String username, String password) {try {String path = "http://172.22.64.156:8080/0001AndroidWebService/LoginServlet?username="+ URLEncoder.encode(username)+ "&password="+ URLEncoder.encode(password);URL url = new URL(path);HttpURLConnection conn = (HttpURLConnection) url.openConnection();conn.setReadTimeout(500);conn.setRequestMethod("GET");int code = conn.getResponseCode();if (code == 200) {// 请求成功InputStream is = conn.getInputStream();String text = StreamUtil.readStream(is);return text;} else {// 请求失败return null;}} catch (Exception e) {e.printStackTrace();}return null;}
0 1
- Android面向HTTP协议发送get请求
- Android面向HTTP协议发送post请求
- http协议get发送请求
- Android 发送请求 HTTP GET/POST
- 使用java 访问发送http协议, 发送Get请求跟Post请求
- android发送get请求
- python发送HTTP GET请求
- python发送HTTP GET请求
- Python发送HTTP GET请求
- lua发送http get请求
- HTTP 发送get post请求
- http发送get、post请求
- Http发送GET/POST请求
- HTTP URLConnection 发送get请求
- Android入门:发送HTTP的GET和POST请求
- Android入门:发送HTTP的GET和POST请求
- Android入门:发送HTTP的GET和POST请求
- Android入门:发送HTTP的GET和POST请求
- Android TabHost
- Xshell下Ubuntu及VIM的配色方案
- 第三章_字符串转换为整数
- Android(安卓)intent打开压缩文件
- POJ——水刷 Hangover
- Android面向HTTP协议发送get请求
- 黑马程序员:__流程控制__
- WebGL 中 OpenGL ES 指令与 iOS 中 C 版指令的差异简析
- emu 启动内核节约时间方法
- Android面向HTTP协议发送post请求
- Android Service与Activity之间通信的几种方式
- 手机网页放缩局部区域原理
- PostgreSQL新手教程
- ibatis返回Date不带时分秒