Exception “Illegal character in query at index -” in Android

雨燕双飞 提交于 2019-12-07 16:33:17

问题


I am trying to send data on server using following link.

**WEBSERVICE LINK:**
http://75.125.237.76/post_reviews.php?data=text1

If I set data filed with single string (ex:data=text1), That time my try block in source code working fine, without any exception.

But When I set data field with multiple string with spaces (ex: data=text1 text2 text3), Then Exception generated i.e. Illegal character in query.

**EXCEPTION:**
Illegal character in query at index 75: http://75.125.237.76/post_reviews.php?data=text1 text2 text3

My question is Why exception generate when we use multiple strings (like: data=My name is xyz).

If I replace data field with single string that time is working fine.(data=xyz)


回答1:


Encode space with %20 have a look at this one for more encodings




回答2:


Encode your URI string so the spaces will be presented as %20



来源:https://stackoverflow.com/questions/12816674/exception-illegal-character-in-query-at-index-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!