HttpPost httpPost=new HttpPost(zbglUrl + "/ChartsSum.in"); 怎么在这次请求中添加param参数
时间: 2023-02-07 10:09:17 浏览: 118
用java写post请求(添加post参数)
可以使用如下方式来添加参数:
```
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("param1", "value1"));
params.add(new BasicNameValuePair("param2", "value2"));
httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
```
然后执行这个HttpPost请求即可。
注意:需要导入以下几个类:
```
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.message.BasicNameValuePair;
```
阅读全文