我需要使用库httpclient 4.0.1
添加用户代理 HttpClientParams httpparams= new HttpClientParams();
HttpClient httpclient = new HttpClient(httpparams);
string userAgent = "my user agent";
if (userAgent != null && userAgent.length() != 0) {
httpclient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, userAgent);
}
我收到此错误消息:
错误:
找不到符号httpclient.getParams()。setParameter(CoreProtocolPNames.USER_AGENT,userAgent);
符号:
变量CoreProtocolPNames
答案 0 :(得分:0)
import org.apache.http.params.CoreProtocolPNames;