JEE Study|JAVA EE|企业级开发学习网

标题: java.net.URISyntaxException [打印本页]

作者: JeeStudy    时间: 2016-12-2 09:08
标题: java.net.URISyntaxException
环境: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() 这种方法会有问题





欢迎光临 JEE Study|JAVA EE|企业级开发学习网 (http://jeestudy.com/) Powered by Discuz! X3.2