Java url中存在非法参数异常

Java url中存在非法参数异常,java,android,json,android-intent,Java,Android,Json,Android Intent,我想使用url请求wfc服务,我在url中添加了三个参数,这是运行时非法参数异常中的错误 logcat 您的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&

我想使用url请求wfc服务,我在url中添加了三个参数,这是运行时非法参数异常中的错误

logcat


您的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"

您的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"
这样做:

这样做:


检查url中的端口号51382和空格检查url中的端口号51382和空格
String myUrl;
myUrl = String.format("http://10.0.2.2:51382/RestServiceImpl.svc/jsons/? Location=%s&GROUP=%s&asondate=%s",items,items1,finalDate);
String url = URLEncoder.encode(myUrl, utf-8); 
System.out.println(url);