I have been engaged in Java web development for more than a year, and I have to write html or jsp pages, and the power of the web application lies in its hyperlink. For example, saving the link address to page b (that is, URI) on page a, but the problem lies in this, how to correctly reference a file. For example, how to quote another HTML page as a hyperlink in one HTML page? How to insert an image into a web page? ......
In addition, relative paths in struts are also popular, and it is easy to be confused if you are not careful.
If the wrong file path is used when citing a file (such as adding a hyperlink, or inserting an image, etc.), the reference will be invalid (the link file cannot be browsed, or the inserted image cannot be displayed, etc.).
In order to avoid these errors, the difference and usage of the file can also be queried in the future.
There are two ways to write HTML: relative paths and absolute pathsHTML relative path
File references to the same directory
If the source file and the reference file are in the same directory, just write the reference file name directly.
We now create a source file info.HTML, and in the info.HTML, we need to refer to the index.HTML file 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 to add index.HTML hyperlink in info.HTML should be written like this:
Copy the code