Html relative and absolute paths and relative paths to solve the photograph does not show

Photos path is divided into absolute and relative paths

1. absolute path is divided into two types, one is the network, one is local
(1) http: // the WWW. Front baidu.com have http: // This is the absolute path on the network, in fact, the actual path is: http://61.135.169.125:80 is the absolute path to the network server
 
 
http://61.135.169.125:80 /image/1.jpg is to visit a picture next Baidu server image folder
 
 
file: // E: /image/1.jpg
(2) means that open 1.jpg file under the absolute path to a local disk image E FILE folder in read mode
It is the root of the Web site as a reference base directory path. It is called absolute, means that when all the pages referenced by the same file, the path used is the same, so unless the file is missing, errors rarely occur.

2. Relative path

Root directory for the reference point of the path described manner is called an absolute path
 
 
With pictures, for example divided into three cases
Here we have created a folder "image" in the WebContent

Html page document also WebContent folder

Prerequisites page and image files to be in the same directory,
(1) If a subdirectory, for example, image inside, with image / 01.gif As shown in the example
(2) if the parent directory is ../01.gif 
 
(. 3) at the same level directory, which e.g. image, .. / images / 123.jpg
 
 

Because the image files into folders in different ways will produce an error

× Copy the file to the image file in the My Computer -eclipse directly covered in the workplace, will produce photo-sync, eclipse image in the folder will not display the new photos into natural web page will not show ×

√将文件复制或直接拖入正在运行的eclipse 所要放的image文件夹中,完成对image文件夹的重写,我们就可以看见image已经显示放入的新文件了√




Guess you like

Origin blog.csdn.net/qq_41850194/article/details/79695034