开发者

Relative path URL problem

Ok. So the problem is here..

on this address i have this url: _http://localhost/blog

img src='image/b.jpg'

and everything goes fine.. because i have my image in "image" folder... browser asking image with this url "_http://localhost/image/b.jpg"

but if i got to: _http://locahost/blog/otherfolder/

then browser start loo开发者_运维百科king for "_http://localhost/blog/image/b.jpg"

I know why this happen. But i only want to know is there a way to set "universal" relative url? That ignore folders and relative to host? By plain HTML

Something like ".. src='{host}/image/b.jpg' .."


 <img src='/image/b.jpg' />


Yeah this is a bit of broken-ness in the web. I mean I am writing JSP tags, and either

  • they write absolute URLs (which requires them to know a bit too much; our URLs are composed of a number of parts which those JSP tags wouldn't really need to know as they navigate only within one section.. i.e. the left part of the URL, beyond a certain point, is always constant... without wanting to bore you with the details..)
  • they write relative URLs which means they can only be used in one "level" of the URL structure (we have pages like /folder1/folder2/page3 etc and those tags can be used anywhere, so that won't work)

So we go with absolute URLs, but it's not ideal.

Not that, if I were designing the web, I would have a better way to do it ....


done this way <img src='/image/b.jpg' />

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜