httpclient简单例子,一种简单的webservice
来源:互联网 发布:淘宝店铺号可以改吗 编辑:程序博客网 时间:2024/04/29 22:43
HttpClient 是 Apache Jakarta Common 下的子项目,可以用来提供高效的、最新的、功能丰富的支持 HTTP 协议的客户端编程工具包,并且它支持 HTTP 协议最新的版本和建议。(来自百度百科)
java代码:
import org.apache.commons.httpclient.HttpClient;import org.apache.commons.httpclient.methods.PostMethod;public class Test{ public static void testHttpClient(String phone, String name) throws IOException { HttpClient httpClient = new HttpClient(); httpClient.getParams().setContentCharset("utf-8");//设置编码 //构造POST请求,GET请求也类似 PostMethod postMethod = new PostMethod(url);//类似http://.... postMethod.addParameter("phone", phone);//Post参数 postMethod.addParameter("name", name); httpClient.executeMethod(postMethod); //解析response StringBuffer buffer = new StringBuffer(); BufferedReader br = new BufferedReader(new InputStreamReader(postMethod.getResponseBodyAsStream(), "utf-8")); String tmpLineStr = ""; while ((tmpLineStr = br.readLine()) != null) { buffer.append(tmpLineStr); } String returnValue = buffer.toString(); System.out.println(returnValue); postMethod.releaseConnection(); }}
0 0
- httpclient简单例子,一种简单的webservice
- webService一种简单的使用
- webservice的简单入门例子
- 简单的webservice开发例子
- 简单的webservice开发例子
- 简单的webservice开发例子
- 简单的webservice开发例子
- 简单的 Java WebService 例子
- httpclient【简单例子】
- HttpClient使用简单例子
- httpClient简单例子
- android中使用HttpClient的简单例子
- axis2 webservice 简单例子
- 天气预报 WebService 简单例子
- CXF简单WebService例子
- CXF简单WebService例子
- webservice简单例子
- webService简单例子
- 用户输入校对函数
- 关于android旋转屏幕时activity重建和android 转屏 onConfigurationChanged 不会执行的问题
- keyup() 方法
- Project Euler:Problem 31 Coin sums
- multiple file upload 多文件上传精典
- httpclient简单例子,一种简单的webservice
- no link present
- C—learning (字符,转义字符,浮点型,printf函数,
- 纪念成为CSDN博客专家
- VisualStudio 路径和项目属性配置
- UML视图
- 批处理学习笔记1:文件搜索
- struts2中对象的获取
- 简易HTTP服务器(epoll模型ET版本)