http请求
2016-01-20 18:45
483 查看
NameValuePair[] data = { new NameValuePair("userName", "aaa"),
new NameValuePair("userPwd", "aaa") };
requestURL = "http://www.baidu.com";
HttpClient httpClient = new HttpClient();
PostMethod postMethod = new PostMethod(requestURL);
postMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
postMethod.setRequestBody(data);
int statusCode = httpClient.executeMethod(postMethod);
logger.info("statusCode ----------: " + statusCode);
String result = postMethod.getResponseBodyAsString();
if (result == null) {
result = "";
}
logger.info(result);
return JSONObject.fromObject(result);
new NameValuePair("userPwd", "aaa") };
requestURL = "http://www.baidu.com";
HttpClient httpClient = new HttpClient();
PostMethod postMethod = new PostMethod(requestURL);
postMethod.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
postMethod.setRequestBody(data);
int statusCode = httpClient.executeMethod(postMethod);
logger.info("statusCode ----------: " + statusCode);
String result = postMethod.getResponseBodyAsString();
if (result == null) {
result = "";
}
logger.info(result);
return JSONObject.fromObject(result);
相关文章推荐
- http error 错误码大全
- C# Http 发送Post请求实例
- tcp cubic代码分析
- AT指令建立TCP/IP 链接,并自收发数据
- TCP三次握手/四次挥手详解
- HTTP协议分析中几种常见的中文编码及其解码
- TCP长连接与短连接的区别
- moo 7 Servlet init() doget() dopost() service()方法之间的区别及应用/GenericServlet、Servlet、HttpServlet借口之间的关系
- git 错误: Unable to find remote helper for 'https'解决方法
- HTTP协议和web工作原理
- 老李分享:https协议
- 电子书《自己动手写神经网络》2016总结
- spring mvc No mapping found for HTTP request with URI [/web/test.do] in DispatcherServlet with name 'spring'
- moon 5. HTTP协议【请求/响应的头部解析】
- Python网络编程
- 【高效server实践】--memcached网络框架剥离实践
- nginx配置https方法
- PHP实现http与https转化
- 解决Spring4.X 报MappingJacksonHttpMessageConverter相关错误
- Markdown - 让网络书写变得简单