【发布时间】:2011-06-02 18:40:39
【问题描述】:
我的 URL 和相对路径(查询)有问题。我编写这段代码是为了从相对 url 中获取绝对 url:
old = "http://domain/script?param";
new_ = "?otherparam";
URL u = new URL(old);
u = new URL(u,new_);
这是输出:
JAVA URL: http://domain/script?param + ?otherparam = http://domain/?otherparam
FireFox: http://domain/script?param + ?otherparam = http://domain/script?otherparam
为什么 URL 的结果与 FireFox 不同?如何像 FireFox 那样构建 URL?
【问题讨论】:
-
是的,Firefox 或任何其他浏览器。
标签: java url relative-path