http post和get请求
来源:互联网 发布:英雄无敌6兵种数据 编辑:程序博客网 时间:2024/05/22 03:36
int httpcode = 0;
String resposeStr = "";
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
HttpClient hc = new HttpClient();
hc.setConnectionTimeout(10000);
hc.setTimeout(8000);
GetMethod pm = new GetMethod(AddresURL);
httpcode = hc.executeMethod(pm);
resposeStr = pm.getResponseBodyAsString();
pm.releaseConnection();
return resposeStr;
}
responseStr = HttpGetSend(supplierServerUrl);
public static String HttpPostSend(String AddresURL,NameValuePair[] nvp) throws Exception {
int httpcode = 0;
String resposeStr = "";
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
HttpClient hc = new HttpClient();
hc.setConnectionTimeout(10000);
hc.setTimeout(8000);
PostMethod pm = new PostMethod(AddresURL);
pm.setRequestBody(nvp);
httpcode = hc.executeMethod(pm);
resposeStr = pm.getResponseBodyAsString();
pm.releaseConnection();
return resposeStr;
}
responseStr = HttpPostSend(supplierServerUrl, nvp);
//流post
public static String HttpPostSend(String AddresURL,String nvp) throws Exception {
int httpcode = 0;
String resposeStr = "";
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
HttpClient hc = new HttpClient();
hc.setConnectionTimeout(10000);
hc.setTimeout(8000);
PostMethod pm = new PostMethod(AddresURL);
pm.addRequestHeader("Content-type",
"application/json; charset=GBK");
pm.setRequestBody(nvp);
httpcode = hc.executeMethod(pm);
resposeStr = pm.getResponseBodyAsString();
pm.releaseConnection();
System.out.println(AddresURL+"|"+httpcode);
return resposeStr;
}
int httpcode = 0;
String resposeStr = "";
HttpClient hc = new HttpClient();
hc.setConnectionTimeout(15000);
hc.setTimeout(15000);
PostMethod pm = new PostMethod(supplierServerUrl);
pm.setRequestBody(nvp);
httpcode = hc.executeMethod(pm);
InputStream is = pm.getResponseBodyAsStream();
BufferedReader br=new BufferedReader(new InputStreamReader(is,"utf-8"));
String line=null;
char[] c=new char[1024];
int len=0;
while(-1 != (len = br.read(c))){
line=new String(c, 0, len);
}
responseStr=line;
pm.releaseConnection();
is.close();
br.close();
- HTTP get和post请求
- http post和get请求
- Http协议(get请求和post请求)
- HTTP post请求和get请求
- HTTP的GET请求和POST请求
- HTTP请求的GET和POST请求
- HTTP的GET请求和POST请求
- http请求,get和post的异同
- http请求,get和post的异同
- http协议之get 和 post请求
- HTTP get和post 请求 浅析
- HTTP的GET和POST请求
- HTTP请求 get和post对比
- java http 请求get 和post
- ios发送http GET和POST请求
- java发送http get 和 post 请求
- HTTP请求:POST和GET的区别
- Http的GET和POST请求
- Java8 Stream API学习笔记
- Nginx+Tomcat负载均衡--win7配置详解
- idea自动上传工程部署文件,远程部署
- constexpr关键字
- Android RelativeLayout(7.1) 源码解析
- http post和get请求
- oracle wm_concat()函数
- DrawerLayout的基本用法SlidingMenu
- UIScrollView Tutorial: Getting Started 缩放
- UCPT 项目总结
- 练习7
- UI设计规范
- eclipse / myeclipse 手动安装 lombok
- sklearn只决策树