你那个不是合理的url/** * Creates a <code>URL</code> object from the <code>String</code> * representation. * <p> * This constructor is equivalent to a call to the two-argument * constructor with a <code>null</code> first argument. * * @param spec the <code>String</code> to parse as a URL. * @exception MalformedURLException If the string specifies an * unknown protocol. * @see java.net.URL#URL(java.net.URL, java.lang.String) */ public URL(String spec) throws MalformedURLException { this(null, spec); }
看一下官方文档,错误原因说的很清楚: public URL(String spec) throws MalformedURLException Creates a URL object from the String representation. This constructor is equivalent to a call to the two-argument constructor with a null first argument.Parameters: spec - the String to parse as a URL. Throws: MalformedURLException - if no protocol is specified, or an unknown protocol is found, or spec is null. See Also: URL(java.net.URL, java.lang.String)
java.net.MalformedURLException: For input string: " monitoring_request_id" 这段异常 前面我知道是url不正确,但是后面还带有 For input string: " monitoring_request_id" 这个 就奇怪了
不能debug的,是后台服务,没有办法debug
java.net.MalformedURLException: For input string: " monitoring_request_id" 这段异常 前面我知道是url不正确,但是后面还带有 For input string: " monitoring_request_id" 这个 就奇怪了 是不是因为你的" monitoring_request_id" 前面多了一个空格,你去掉试试。
java.net.MalformedURLException: For input string: " monitoring_request_id" 这段异常 前面我知道是url不正确,但是后面还带有 For input string: " monitoring_request_id" 这个 就奇怪了 是不是因为你的" monitoring_request_id" 前面多了一个空格,你去掉试试。 这个我是过了,不是因为空格
* Creates a <code>URL</code> object from the <code>String</code>
* representation.
* <p>
* This constructor is equivalent to a call to the two-argument
* constructor with a <code>null</code> first argument.
*
* @param spec the <code>String</code> to parse as a URL.
* @exception MalformedURLException If the string specifies an
* unknown protocol.
* @see java.net.URL#URL(java.net.URL, java.lang.String)
*/
public URL(String spec) throws MalformedURLException {
this(null, spec);
}
public URL(String spec)
throws MalformedURLException
Creates a URL object from the String representation.
This constructor is equivalent to a call to the two-argument constructor with a null first argument.Parameters:
spec - the String to parse as a URL.
Throws:
MalformedURLException - if no protocol is specified, or an unknown protocol is found, or spec is null.
See Also:
URL(java.net.URL, java.lang.String)
这段异常 前面我知道是url不正确,但是后面还带有 For input string: " monitoring_request_id" 这个 就奇怪了
这段异常 前面我知道是url不正确,但是后面还带有 For input string: " monitoring_request_id" 这个 就奇怪了
是不是因为你的" monitoring_request_id" 前面多了一个空格,你去掉试试。
这段异常 前面我知道是url不正确,但是后面还带有 For input string: " monitoring_request_id" 这个 就奇怪了
是不是因为你的" monitoring_request_id" 前面多了一个空格,你去掉试试。
这个我是过了,不是因为空格
if (!content.startsWith("http://") && !content.startsWith("https://")) {
content = "http://" + content;
} URL url = new URL(content); // 这里应该是 http://xxxxx.com/api.php?monitoring_request_id=c0e715dd2336d7r5a8188were5e5b6af70534de2f30eda40.93250950&sequence=534o0ijer”;
这段异常 前面我知道是url不正确,但是后面还带有 For input string: " monitoring_request_id" 这个 就奇怪了
是不是因为你的" monitoring_request_id" 前面多了一个空格,你去掉试试。
这个我是过了,不是因为空格
应该是你从数据库读出来的数据问题,我把你的代码在本地测了一下没问题:import java.net.MalformedURLException;
import java.net.URL;public class Test { /**
* @param args
*/
public static void main(String[] args) {
String content = "http://xxxxx.com/api.php?monitoring_request_id=c0e715dd2336d7r5a8188were5e5b6af70534de2f30eda40.93250950&sequence=534o0ijer";
try {
if (!content.startsWith("http://")
&& !content.startsWith("https://")) {
content = "http://" + content;
}
URL u = new URL(content);
String u1 = u.getHost();
System.out.println(u1);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}}
这段异常 前面我知道是url不正确,但是后面还带有 For input string: " monitoring_request_id" 这个 就奇怪了
是不是因为你的" monitoring_request_id" 前面多了一个空格,你去掉试试。
这个我是过了,不是因为空格
应该是你从数据库读出来的数据问题,我把你的代码在本地测了一下没问题:import java.net.MalformedURLException;
import java.net.URL;public class Test { /**
* @param args
*/
public static void main(String[] args) {
String content = "http://xxxxx.com/api.php?monitoring_request_id=c0e715dd2336d7r5a8188were5e5b6af70534de2f30eda40.93250950&sequence=534o0ijer";
try {
if (!content.startsWith("http://")
&& !content.startsWith("https://")) {
content = "http://" + content;
}
URL u = new URL(content);
String u1 = u.getHost();
System.out.println(u1);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}}
这个确实很奇怪,数据库数据我也看了,都很正常,所以。很不解啊,用到了httpsqs队列,等到明天我在看看,在做回复吧,谢谢了