[英]Caused by: java.lang.IllegalArgumentException: Illegal character in query at index 120
I am using the following url for fetching values from server.我正在使用以下 url 从服务器获取值。
http://yyy.com/2013-01-01/search?q=t*&q.options={"defaultOperator":"and","fields":["name"]}&fq=(and directorytype:'directory1')
I am gettting the following error when running the app运行应用程序时出现以下错误
Caused by: java.lang.IllegalArgumentException: Illegal character in query at index 201
The error is pointing to the following line of code
HttpGet httpget = new HttpGet(URL);
Can anybody help任何人都可以帮忙
You need to encode your parameters values.您需要对参数值进行编码。 You can't have spaces,*,(,) and many more characters in your url, for example space should be %20 instead.
您的网址中不能有空格、*、(,) 和更多字符,例如空格应为 %20。 Use
java.net.URLEncoder.encode(String s, String encoding)
to encode them.使用
java.net.URLEncoder.encode(String s, String encoding)
对它们进行编码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.