使用if("get".equals(strMethod.toLowerCase())) method = new HttpGet(uri);
,
报错:
Exception in thread "main" java.lang.IllegalArgumentException
at java.net.URI.create(URI.java:842)
at org.apache.http.client.methods.HttpGet.<init>(HttpGet.java:69)
at Visitall.RenRenNotify.notify(RenRenNotify.java:153)
at Visitall.RenRenNotify.main(RenRenNotify.java:317)
导致问题的原因,是因为在URL参数中,带了特殊字符,
需要对({}、&、空格。。。)之类的特殊字符重新进行编号 ,
URL url = new URL(strUrl);
URI uri = new URI(url.getProtocol(),null, url.getHost(),url.getPort(), url.getPath(), url.getQuery(), null);