Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 索引处的查询中存在非法字符_Android - Fatal编程技术网

Android 索引处的查询中存在非法字符

Android 索引处的查询中存在非法字符,android,Android,我正在使用HTTPGET请求从服务器获取数据。当我传递url时,ir给我的错误是 04-29 11:30:56.514: V/Exception(7745): Illegal character in query at index 129 但我点击了浏览器上的url,它给了我正确的回应 我正在为HTTPGET DefaultHttpClient httpClient = new DefaultHttpClient(); try { HttpGet httpGet

我正在使用
HTTPGET
请求从服务器获取数据。当我传递url时,ir给我的错误是

04-29 11:30:56.514: V/Exception(7745): Illegal character in query at index 129
但我点击了浏览器上的url,它给了我正确的回应

我正在为
HTTPGET

    DefaultHttpClient httpClient = new DefaultHttpClient();
    try {
        HttpGet httpGet = new HttpGet(url);
        HttpResponse httpResponse = httpClient.execute(httpGet);
        HttpEntity httpEntity = httpResponse.getEntity();
        is = httpEntity.getContent();
        return processRequest(is).toString();
    } catch (Exception exception) {
        Log.v("Exception", exception.getMessage());
    }

您需要对URL进行编码

像这样,

try {

    String simpleUrl = "http://www.abc.com/?email=abc&pass=efg";
    String encodedurl = URLEncoder.encode(url,"UTF-8");

} catch (UnsupportedEncodingException e) {
    e.printStackTrace();
}

现在将
encodedurl
String传递给
newhttpget(encodedurl)

发布查询字符串以查找索引12904-29 11:30:56.514:V/Exception(7745):索引129:04-29 11:30:56.514:V/Exception(7745)查询中的非法字符:rwrQMYYRv88Y9WZUleXQjgKA8NBuq5DkaA04-29 11:45:02.421:V/Exception(9040):目标主机不能为null,也不能在参数中设置。scheme=null,host=null,path=paste您的url字符串?04-29 11:47:41.069:V/encodedeo url(9369):http%3A%2F%2F192.168.1.43%2FEnc%2Fexamples%2Fdecrypt.php%3FMessage%3dawfpwEx9xxntmfga8ufgsqpr3ajfqwwwymsy%2bqt2wbs8ft6ntmytn91riowkgmar6rwnz370tn4l%0Ac%2fdmtl1%2fdydpdg96ysnpkuh0ju9r%kka%0A04-499:93v文本密码:请在开头添加
http://
https://
。注意:此url在网络上不存在,请使用有效路径。它给出404错误意味着url不存在。
String link="http://example.php?string1="+URLEncoder.encode(string1)+"&string2="+URLEncoder
.encode(string2)+"&string3="+URLEncoder.encode(string3)+"&string4="+URLEncoder.encode(string4)+"";