Java-absolute address and relative address/absolute location and relative location

Source: Internet
Author: User

Q: What are the absolute and relative addresses? Absolute and relative positioning?
A: the absolute address, such as the absolute address;
Relative address: the address of the linked file relative to the current page. For example, you only need to use "file name" for the file address at the same level as the current page; use "directory name/file name" to link the files under the subdirectories of the current page; Use ".. /file name "; link to the same level but use" .. /directory name/file name "; you can use". /file name.
In fact, it is absolutely and relatively easy to understand. It is definitely a fixed object with a reference.
Why do we advocate relative addresses? To put it bluntly, if you have an index.htm file that references some images in the images directory, and if you use a relative address, you only need to upload all the original items to the new space during migration, because the relative positional relationship between Files remains unchanged, these addresses are still valid. However, if an absolute address is used when an image is inserted, the address of the space changes and the path of the referenced image changes accordingly. Of course, absolute addresses are sometimes used, such as links to others' homepages.
The same is true for relative positioning. If the layer is located relative to a cell, where the cell moves, the layer will be located. Combined with this Article "relative to absolute positioning of the layer", it can solve the problem that the layer is difficult to adapt to multiple resolutions:
Http://www.windstudio.net/html/200403/20040309171408.htm
From a dialectical point of view, absolute positioning is actually relative. The difference between it and what we call relative positioning is that the absolute positioning of layers is relative to the left border and upper border of the browser, the relative positioning of a layer is relative to its carrier (table or another layer.
The following describes the differences between relative paths and absolute paths in actual practice.

.
The Link Description in the source code of the hosts file should be: <a href = "01/1. htm"> Link Description </a> where 01/1. HTM extension 1.htmis relative to index.htm. From 1.htmto index.htm, how should I write this path description? First, let's take a look at the code: <a href = ".. /index.htm "> Link Description </a> you will see two points in the Link path. Here we use the parent path. The two points mean to return to the upper-level folder, and so on, returns the number of two points that should appear in the top-level folder. The relative path has been explained.
The following describes the absolute path problem.
For example, if you have a virtual host that is bound to the domain name www.jianzhan8.cn, then you can access your website by entering a http://www.jianzhan8.cn in your browser. First, we need to upload all the webpage files in our example to the virtual website. Then, we have to find that the absolute address of index.htm on the internet is
<A href = "http://www.jianzhan8.cn/01/1.htm"> Link Description </a>, the code for using absolute paths to index.htm is written as <a href = "http://www.jianzhan8.cn/index.htm"> Link Description </a>.
Suggestions on path usage
If it is a file in the site, we recommend that you use a relative path, because it is shorter than the absolute path code, and the relative location is also easier to find, making website maintenance more convenient. The absolute path is generally used for external resource links.

Relative address refers to the address relative to an object (usually relative to the root directory of a website ).
It has nothing to do with whether it is on this machine.
The absolute address is the absolute address on the resource Internet.

For example
If you create a website
An image (figure 1) uses an absolute address.
(Eg: IMG src = "http://www.aaa.com/images/1.gif ")
The corresponding link is used for another image (figure 2 ).
(Eg: IMG src = "images/2.gif"
Relative to the website root directory resolution to http://www.aaa.com/images/2.gif)
So when you want to migrate the site to www.bbb.com (this is a common issue)
Figure 1 will be resolved to the http://www.aaa.com/images/1.gif
Figure 2 resolve to http://www.bbb.com/images/2.gif
Let's see what's going on.

In short, the absolute address starts from the drive letter, and the relative address is relative to the address of the current folder.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.