I have been engaged in Java web development for more than a year. It is inevitable to write HTML or JSP pages. The power of web applications lies in its hyperlinks (Hyper Link). For example, in page a, save the link address pointing to page b ( That is, URI), but the problem lies precisely here, how to correctly reference a file. For example, how to reference another HTML web page as a hyperlink in an HTML web page? How to insert an image into a web page? ......
In addition, relative paths are also very popular in struts, and it is easy to get confused if you are not careful.
If you use the wrong file path when referencing a file (such as adding a hyperlink, or inserting a picture, etc.), the reference will become invalid (the linked file cannot be browsed, or the inserted picture cannot be displayed, etc.).
In order to avoid these errors, cite the documents correctly and write down the differences and usages so that you can check them in the future.
HTML has two ways of writing paths: relative paths and absolute paths
HTML relative path (relative path)
File references in the same directory
If the source file and the reference file are in the same directory, just write the name of the reference file directly.
We now create a source file info.HTML, and reference the index.HTML file as a hyperlink in info.HTML.
Assume the info.HTML path is: d:tomcatwebappshelloblablainfo.HTML
Assume the index.HTML path is: d:tomcatwebappshelloblablaindex.HTML
The code to add the index.HTML hyperlink to info.HTML should look like this Write:
How to represent the upper-level directory ../ represents the upper-level directory of the directory where the source file is located, .. /../ represents the upper-level directory of the directory where the source file is located, and so on.
Assume the info.HTML path is: d:tomcatwebappshelloblablainfo.HTML
Assume the index.HTML path is: d:tomcatwebappshelloindex.HTML
The code to add the index.HTML hyperlink to info.HTML should look like this Write:
Assume the info.HTML path is: d:tomcatwebappshelloblablawowstoryinfo.HTML
Assume the index.HTML path is: d:tomcatwebappshelloindex. HTML
The code to add index.HTML hyperlink to info.HTML should be written like this:
Assume the info.HTML path It is: d:tomcatwebappshelloblablainfo.HTML
Assume the index.HTML path is: d:tomcatwebappshellowowstoryindex.HTML
The code to add the index.HTML hyperlink to info.HTML should be written like this:
How to represent the lower-level directory refers to the file in the lower-level directory, just write the path of the file in the lower-level directory directly.
Assume the info.HTML path is: d:tomcatwebappshelloblablainfo.HTML
Assume the index.HTML path is: d:tomcatwebappshelloblablaHTMLindex.HTML
The code to add the index.HTML hyperlink to info.HTML should look like this Write:
Assume the info.HTML path is: d:tomcatwebappshelloblablainfo.HTML
Assume the index.HTML path is: d:tomcatwebappshelloblablaHTMLtutorialsindex.HTML
The code to add index.HTML hyperlink to info.HTML should be written like this:
HTML absolute path (absolute path)
HTML absolute path (absolute path) refers to the full path of a file with a domain name.
Suppose you register the domain name www.jb51.net and apply for a virtual host. The virtual host provider will give you a directory, such as www. This www is the root directory of the website.
Assume that a file index.HTML is placed in the www root directory. The absolute path of this file is: http://www.jb51.net/index.html.
Assume that in the www root directory Create a directory called HTML_tutorials under the directory, and then place a file index.HTML in the directory. The absolute path of this file is http://www.jb51.net/article/32759.htm.