异常“索引中查询中的非法字符”在Android中 [英] Exception "Illegal character in query at index -" in Android

查看:210
本文介绍了异常“索引中查询中的非法字符”在Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

如果我将数据归档单字符串(例如:data = text1),那时候我的源代码中的try块工作正常,没有任何异常。



但是当我将数据字段设置为多个字符串时空格(例如:data = text1 text2 text3),然后生成异常,即查询中的非法字符。

  ** EXCEPTION:** 
索引75查询中的非法字符:http://75.125.237.76/post_reviews.php?data=text1 text2 text3

我的问题是为什么当我们使用多个字符串时会产生异常(如:data = My name is xyz)。



< (数据= xyz)

解决方案

编码空格%20 看看这一个用于更多编码


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)

解决方案

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

这篇关于异常“索引中查询中的非法字符”在Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆