HttpClient post提交数据,汉字转码
2024-08-31 03:32:04
public static String post(String url, String data) throws ClientProtocolException, IOException {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
//设置请求和传输超时时间
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(60000).setConnectTimeout(60000).build();
httpPost.setConfig(requestConfig);
httpPost.setHeader("Content-Type","application/json; charset=utf-8");
httpPost.setEntity(new StringEntity(data.toString(), Charset.forName("UTF-8")));
HttpResponse response = httpClient.execute(httpPost);
String httpEntityContent = getHttpEntityContent(response);
httpPost.abort();
return httpEntityContent;
}
最新文章
- MySql 绿色版配置
- JSP基础语法
- Java实现注册时发送激活邮件+激活
- The quieter you become,The more you are able to hear.
- .NET技术在中国为什么老被人嫌弃
- git branch用法总结
- ABBYY PDF Transformer+ Pro支持全世界189种语言
- jquery 常用组件的小代码
- sencha touch xtype
- HTML特殊字符编码大全
- 三、FreeMarker 模版开发指南 第三章 模版
- Python读入与写出中文时出现乱码
- (转)C++中extern “C”含义深层探索
- Codecademy学习打卡1
- Python 2.7 学习笔记 内置语句、函数、标准库
- Wind River Linux 6 Security Profile
- OpenGL红宝书例子2.2 uniform变量的使用
- Fliptile 翻格子游戏[Usaco2007 Open]
- Linux - 简明Shell编程12 - 定制输出(ColorOutput)
- Oracle实战笔记(第七天)之PL/SQL进阶
热门文章
- 深度学习方法(十一):卷积神经网络结构变化——Google Inception V1-V4,Xception(depthwise convolution)
- (转)OpenCV 访问Mat中每个像素的值
- android4.0 锁屏实现(转)
- fastdfs5.11+centos7.2 按照部署(三)【转载】
- day2 购物商城
- iis应用池内存溢出卡死优化
- Three.js基础探寻七——Lamber材质与Phong材质
- Eclipse中Tomcat 修改后台代码即时生效
- 关于 bitset 的一些题目
- 洛谷——P1330 封锁阳光大学