环境:win server 2008 R2
WAS:7.0.0.11
异常:java.net.URISyntaxException: Illegal character in path at index 16: file:/C:/Program Files (x86)/IBM/WebSphere/AppServer/profiles/AppSrv02/installedApps/WIN-PCNode02Cell/XXX_war.ear/XXX_bj.war/WEB-INF/classes/com/jeestudy/
原因:URI中包含空格
解决方案:
URL eurl = urls.nextElement();
String urlPath = eurl.getProtocol() + ":" + URLEncoder.encode(eurl.getPath(), "UTF-8");
eurl = new URL(urlPath);
[Java] 纯文本查看 复制代码 URL eurl = urls.nextElement();
String urlPath = eurl.getProtocol() + ":" + URLEncoder.encode(eurl.getPath(), "UTF-8");
eurl = new URL(urlPath);
备注:eurl.toURI().toString() 这种方法会有问题
|