The powerful function of a web application lies in its HyperLink. For example, the link address (URI) pointing to page B is saved on page a, but the problem is exactly here, correctly reference an object. For example, how to reference another HTML webpage in an HTML webpage as a hyperlink (hyperlink) for java web development has been around for more than a year, and it is inevitable to write html or jsp pages, the powerful function of a web application lies in its Hyper Link. For example, the Link address (URI) pointing to page B is saved on page a, but the problem is exactly here, correctly reference an object. For example, how to reference another HTML webpage as a hyperlink in an HTML webpage )? How can I insert an image into a webpage ?......
In addition, the relative paths in struts are also quite popular, so it is easy to confuse them accidentally.
If you use an incorrect file path when referencing a file (such as adding a hyperlink or inserting an image), the reference will become invalid (you cannot browse the linked file, or the inserted image cannot be displayed ).
In order to avoid these errors and reference files correctly, write down the differences and usage of the users, which can be queried in the future.
HTML has two paths: relative path and absolute path.
Relative path)
File reference in the same directory
If the source file and the Referenced File are in the same directory, you can directly write the referenced file name.
Create a source file info. HTML. reference the index. HTML file in info. HTML as a hyperlink.
Assume that the info. HTML path is d: \ tomcat \ webapps \ hello \ blabla \ info. HTML.
Assume that the index. HTML path is d: \ tomcat \ webapps \ hello \ blabla \ index. HTML.
The code for adding the index. HTML hyperlink to info. HTML should be written as follows:
The Code is as follows:
Index. HTML
How to represent the parent directory
.../Indicates the upper-level directory of the directory where the source file is located,.../indicates the upper-level directory of the directory where the source file is located, and so on.
Assume that the info. HTML path is d: \ tomcat \ webapps \ hello \ blabla \ info. HTML.
Assume that the index. HTML path is d: \ tomcat \ webapps \ hello \ index. HTML.
The code for adding the index. HTML hyperlink to info. HTML should be written as follows:
The Code is as follows:
Index. HTML
Assume that the info. HTML path is d: \ tomcat \ webapps \ hello \ blabla \ wowstory \ info. HTML.
Assume that the index. HTML path is d: \ tomcat \ webapps \ hello \ index. HTML.
The code for adding the index. HTML hyperlink to info. HTML should be written as follows:
The Code is as follows:
Index. HTML
Assume that the info. HTML path is d: \ tomcat \ webapps \ hello \ blabla \ info. HTML.
Assume that the index. HTML path is d: \ tomcat \ webapps \ hello \ wowstory \ index. HTML.
The code for adding the index. HTML hyperlink to info. HTML should be written as follows:
The Code is as follows:
Index. HTML
How to represent a sub-directory
Reference the file in the lower-level directory and directly write the path of the lower-level directory file.
Assume that the info. HTML path is d: \ tomcat \ webapps \ hello \ blabla \ info. HTML.
Assume that the index. HTML path is d: \ tomcat \ webapps \ hello \ blabla \ HTML \ index. HTML.
The code for adding the index. HTML hyperlink to info. HTML should be written as follows:
The Code is as follows:
Index. HTML
Assume that the info. HTML path is d: \ tomcat \ webapps \ hello \ blabla \ info. HTML.
Assume that the index. HTML path is d: \ tomcat \ webapps \ hello \ blabla \ HTML \ tutorials \ index. HTML.
The code for adding the index. HTML hyperlink to info. HTML should be written as follows:
The Code is as follows:
Index. HTML
Absolute HTML path (absolute path)
Absolute path refers to the complete path of the file with a domain name.
Assume that you have registered the domain name www.jb51.net and applied for a VM. the provider of the VM will give you a directory, such as www, which is the root directory of the website.
Suppose a file index. HTML is put under the www root directory, the absolute path of this file is: http://www.jb51.net/index.html.
Assume that a directory named HTML_tutorials is created under the www root directory, and a file index. HTML is assigned to the directory. The absolute path of the file is http://www.jb51.net/article/32759.htm.