绝对路径相对路径 [英] Absolute path & Relative Path

查看:153
本文介绍了绝对路径相对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

绝对路径&的区别是什么?使用任何Web服务器或Tomcat时的相对路径?

解决方案

绝对路径以/开头,并且指向当前站点(或虚拟主机)根目录中的某个位置.

相对路径不是以/开头,而是从引用所在文档的实际位置开始引用.

示例,假设root为 http://foo.com/site/

绝对路径,无论我们在网站上的什么位置

/foo.html

将引用 http://foo.com/site/foo.html

相对路径,假设包含链接位于 http://foo.com/site/part1/bar.html

../part2/quux.html

将引用 http://foo.com/site/part2/quux.html

part2/blue.html

将引用 http://foo.com/site/part1/part2/blue .html

What's the difference between absolute path & relative path when using any web server or Tomcat?

解决方案

Absolute paths start with / and refer to a location from the root of the current site (or virtual host).

Relative paths do not start with / and refer to a location from the actual location of the document the reference is made.

Examples, assuming root is http://foo.com/site/

Absolute path, no matter where we are on the site

/foo.html

will refer to http://foo.com/site/foo.html

Relative path, assuming the containing link is located in http://foo.com/site/part1/bar.html

../part2/quux.html

will refer to http://foo.com/site/part2/quux.html

or

part2/blue.html

will refer to http://foo.com/site/part1/part2/blue.html

这篇关于绝对路径相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆