java.net.URISyntaxException: Illegal character in query at index 44
下载 httpclient 源码 http://hc.apache.org/downloads.cgi
然后修改 httpcomponents-client-4.3.6\httpclient\src\main\java\org\apache\http\impl\client\DefaultRedirectStrategy.java 中的方法 createLocationURI
1 import java.io.UnsupportedEncodingException; 2 import java.net.URLEncoder; 3 4 5 6 protected URI createLocationURI(final String location) throws ProtocolException { 7 try { 8 String url = URLEncoder.encode(location,"utf-8"); 9 final URIBuilder b = new URIBuilder(new URI(url).normalize()); 10 //final URIBuilder b = new URIBuilder(new URI(location).normalize()); 11 final String host = b.getHost(); 12 if (host != null) { 13 b.setHost(host.toLowerCase(Locale.ENGLISH)); 14 } 15 final String path = b.getPath(); 16 if (TextUtils.isEmpty(path)) { 17 b.setPath("/"); 18 } 19 return b.build(); 20 } catch (final URISyntaxException ex) { 21 throw new ProtocolException("Invalid redirect URI: " + location, ex); 22 }catch(UnsupportedEncodingException ex){ 23 throw new ProtocolException("Invalid redirect URI: " + location, ex); 24 } 25 }
mvn -Dtest -DfailIfNoTests=false package
编译好的文件下载 httpclient-4.3.6.jar.zip
转载于:https://www.cnblogs.com/JesseYang/p/4211201.html