作者:风语飘散 | 来源:互联网 | 2023-05-18 15:45
现在httpParams类不能用了吗?那现在要如何获取和设置参数呢?想设置连接超时来着。。
4 个解决方案
http://www.cnblogs.com/hemingwang0902/archive/2012/05/28/2522185.html
那现在要如何获取和设置参数呢?想设置连接超时来着
re:
问的太抽像是.是在请求还是响应中设置参数
[code type=java]
int CONNECTION_TIMEOUT = timeout * 1000; // timeout in millis
RequestConfig requestConfig = RequestConfig.custom()
.setConnectionRequestTimeout(CONNECTION_TIMEOUT)
.setConnectTimeout(CONNECTION_TIMEOUT)
.setSocketTimeout(CONNECTION_TIMEOUT)
.build();
HttpPost httpPost = new HttpPost(URL);
httpPost.setConfig(requestConfig);
[/code]
使用RequestConfig来代替HttpParams进行设置,如楼上所写