1、httpPost 设置header,header内容是在发送请求的头文件里面
HttpPost httpPost = new HttpPost(url);
如:
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
2、StringEntity 设置header,header内容是在发送的内容里面
StringEntity stringEntity = new StringEntity(data, ToolString.encoding);
如:
<!DOCTYPE html>
<html id="spLianghui">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
3、HttpResponse 设置header,header内容是在获取返回信息的头文件里面
HttpResponse response = httpClient.execute(httpPost);
原文地址:http://blog.51cto.com/1197822/2157329
时间: 2024-11-02 14:39:45