【发布时间】:2013-03-05 18:05:43
【问题描述】:
我有一个类似 mypage.com/a/b/somePage.html 的页面,其中一个锚点 href 属性类似于“a/b/anotherPage.html”。
当我尝试通过创建具有页面 url 和 href 值的新 url 对象来获取绝对 url 时,我得到的绝对 url 为 mypage.com/a/b/a/b/anotherPage.html。
这给我带来了问题,但浏览器如何正确处理这个问题。
可用于解决此问题的任何现成可用的东西。 (我总是可以在代码中添加一个异常来以不同的方式处理这个问题,但我不想这样做。)
【问题讨论】:
-
尝试类似 ` URL url = new URL( new URL("google.com/a/b/page.html") , "a/b/page2.html"); System.out.println(url); `跨度>
标签: url web-crawler relative-url