java - url 中的非法参数异常

标签 java android json android-intent

i want to request wfc service by using url and i add three parameter in url it was error in run time illegal argument exception

String myUrl;
    myUrl = String.format("http://10.0.2.2:51382/RestServiceImpl.svc/jsons/? Location=%s&GROUP=%s&asondate=%s",items,items1,finalDate);

logcat

07-03 10:04:31.602: E/AndroidRuntime(2790): java.lang.RuntimeException: Unable to start activity
  ComponentInfo{com.androidhive.innovate/com.androidhive.innovate.AndroidJSONParsingActivity}: java.lang.IllegalArgumentException: Illegal character in query at index 49: http://10.0.2.2:51382/RestServiceImpl.svc/jsons/? Location=ArihantWanarpet&GROUP=ArihantShowroom&asondate=2013-07-03

最佳答案

您的 URL 中 ? 之后有一个空格。摆脱它,我想你会没事的,一切都会好起来的。所以这个:

"http://10.0.2.2:51382/RestServiceImpl.svc/jsons/? Location=%s&GROUP=%s&asondate=%s"

成为

"http://10.0.2.2:51382/RestServiceImpl.svc/jsons/?Location=%s&GROUP=%s&asondate=%s"

关于java - url 中的非法参数异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17447285/

相关文章:

java - 如何以编程方式创建 Spring 计划作业?

android - ImageReader Android 无法读取任何图像

android - 尝试打开 GraphicLayout 时 Eclipse 中的 java.lang.NullPointerException?

json - Ebay API JSON 请求

javascript - jquery json ..对数据数组自定义列表进行排序..如何?

java - 将文件和 JSON 数据发布到 Spring rest 服务

java - ObjectMapper readValue 类型从 LinkedHasMap 转换为自定义类型

java - 这段代码到底做了什么?

android - BLE扫描记录说明

c# - 字符串数组未正确序列化为 json?