我需要做些什么来解决“java.lang.IllegalArgumentException”? [英] What I have to do to solve "java.lang.IllegalArgumentException"?

查看:140
本文介绍了我需要做些什么来解决“java.lang.IllegalArgumentException”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过HttpGet()方法处理以下URL:

I am trying to process the following URL via the HttpGet() method:

https://graph.facebook.com/search?q=Cafe++Bakery& ; type = event& access_token =& type = event& access_token = 239090718395 | lqqOnRWlcJOb3QGp3G4HW2aqhlc

我得到以下异常:

java.lang.IllegalArgumentException: 
Invalid uri 'https://graph.facebook.com/search?q=Cafe++Bakery&type=event&access_token=&type=event&access_token=239090718395|lqqOnRWlcJOb3QGp3G4HW2aqhlc.': Invalid query
    at org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:222)
    at org.apache.commons.httpclient.methods.GetMethod.<init>(GetMethod.java:89)

现在,当我削减&将该URL粘贴到浏览器中,它工作正常。我是
猜测这是一些URL编码需要发生,但我不知道我必须改变什么来从Http客户端调用url。

Now when I cut & paste that URL into the browswer it works just fine. I am guess it is some sort of URL Encoding that needs to occur, but I am not sure what I have to change to call url from Http Client.

提前感谢

推荐答案

使用 URLEncoder.encode()

Use URLEncoder.encode() to encode the URL

这篇关于我需要做些什么来解决“java.lang.IllegalArgumentException”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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