客户端发一个post请求
2024-10-01 02:50:13
public static String doPostStr(String httpUrl, String str) {
HttpPost httpPost = null;
try {
HttpClient client = getHttpClient();
httpPost = new HttpPost(httpUrl);
StringEntity entity = new StringEntity(str);
entity.setContentType("application/x-www-form-urlencoded");
entity.setContentEncoding("utf-8"); httpPost.setEntity(entity); HttpResponse response = client.execute(httpPost);
String result = EntityUtils.toString(response.getEntity(), DEFAULT_CHARSET);
return result;
} catch (Exception e) {
logger.error("http post is error," + e.getMessage(), e.fillInStackTrace());
} finally {
httpPost.releaseConnection();
}
return null;
}
最新文章
- 23种oop设计模式定义
- RedHat Enterprise Linux 7关闭防火墙方法
- Android常用抓包工具之TcpDump
- 常见HTTP状态基本解释
- LINUX 下通过lsof恢复被误删除的文件
- oracle 10g 学习之服务器端安装(1)
- .NET Framework Execution Was Aborted By Escalation Policy
- (转)在网页中JS函数自动执行常用三种方法
- springmvc中forward和redirect
- Poj 2707 Copier Reduction
- [C++ 2011 STL (VS2012 Update4) 源代码阅读系列(2)]熟悉一些宏定义和模版偏特化或叫模版专门化
- node多版本管理--nvmw
- Unity 游戏框架搭建 (二十) 更安全的对象池
- php 运行的四种模式
- jQuery 属性操作方法(五)
- Function方法和属性图
- 51NOD 1705 七星剑 [DP 期望的线性性质]
- [软件研究]对AMH面板的研究
- IBM MQ相关 ---- 系列文章
- java8时间操作