80,348
社区成员
发帖
与我相关
我的任务
分享
HttpGet get = new HttpGet(URLEncoder.encode(url,"UTF-8"));
String query = URLEncode.encode("name");
query += "=";
query += URLEncode.encode("han");
query += "&";
query += URLEncode.encode("content");
query += "=";
query += URLEncode.encode("hello world");
String url = "http://baidu.com?"+query;
String url="http://baidu.com?name=han&content=hello world";
HttpGet get = new HttpGet(URLEncoder.encode(url,"UTF-8"));
然后报异常了:
java.lang.IllegalStateException: Target host must not be null, or set in parameters. scheme=null, host=null, path=http://baidu.com?name=han&content=hello world
是不是不应该把整个url给Encode了啊?如果只Encode后面的请求语句的话,再怎么和前面的http://baidu.com拼在一起呢?