当前位置:网站首页>了解各种路径
了解各种路径
2022-07-29 00:29:00 【M78_国产007】
路径可分为相对路径和绝对路径
再一步细分本地相对路径和本地绝对路径、网络相对路径和网络绝对路径、本地相对根路径和网络相对根路径。
本地绝对路径
就是我们计算机中一个文件的完整显示路径,如:

这里所示的就是一个绝对路径,从计算机的根盘符开始一级一级写到我们所需的文件所处位置。
本地相对路径
相对于当前文件所在的文件路径,在引入外部文件时我们大多数都是使用的相对路径。
举个例子:
我们在html文档中导入图片 <img src="./img/jj2.jpg">,这里的"./"也可以直接不写"./"都表示表示相对于这个html文档所在的文件路径下它存在的那个文件夹位置,html的所处位置为D:\h5\后端\code\node\jtweb,那么这个图片位置就为D:\h5\后端\code\node\jtweb\img\jj2.jpg
网络绝对路径
就是一条完整的网址:http://ip:端口/访问地址?querystring#hash
记住必须要写协议!我们在浏览器输入网址不用输协议,是因为浏览器有纠错功能,会自动给我们加上,但是我们编程的时候不能。
网络相对路径
是相对于当前服务器访问地址所处的那个路径。
比如:当前网址:"协议://ip:port /src/news/index.html querystring hash"
页面内部会有src和href等网络请求,如"./src/18.jpg",它是相对于index.html所处位置,它完整形式为"协议://ip:port /src/news/src/18.jpg",同样与本地相对路径一样,可以不写"./","src/18.jpg"也是一样的。
思考1:
用户输入网址:" http://192.168.1.3:8080/user/ro/tupian/a.html?n=20"
打开了一个页面,在这个页面中有一个img的src是 : "./img/jj2.jpg"
请问这个图片的真正网址是什么
答: "http://192.168.1.3:8080/user/ro/tupian/img/jj2.jpg"
思考2:
用户输入网址:"http://192.168.1.3:8080/user/ro/tupian"
打开了一个页面,在这个页面中有一个img的src是 :"./img/jj2.jpg"
请问这个图片的真正网址是什么
答:它真正的网址:"http://192.168.1.3:8080/user/ro/img/jj2.jpg"
本地相对根路径
用"/"表示, 写法:<img src="/img/jj2.jpg">,这时这个图片的路径直接相对于它所在的磁盘,如果是在C盘,那么完整路径就是C:/img/jj2.jpg。
网络相对根路径
也是用"/"表示,src='/img/jj2.jpg',在网络请求中,直接相对于端口后面的位置。
如:
用户输入网址: http://192.168.1.3:8080/user/ro/tupian
打开了一个页面,在这个页面中有一个img的src是 : "/img/jj2.jpg"
请问这个图片真正的网址是什么?
答:它真正的网址:"http://192.168.1.3:8080/img/jj2.jpg"
边栏推荐
- Linux redis source code installation
- DVWA之SQL注入
- IT硬件故障的主要原因和预防的最佳实践
- 一文搞懂ES6基本全部语法
- Recommended Spanish translation of Beijing passport
- Error installing mysqlclient module on MAC system
- Flash reports an error: type object 'news' has no attribute' query 'the view name is duplicate with the model name
- Main causes of IT hardware failures and best practices for prevention
- 测试/开发程序员靠技术渡过中年危机?提升自己本身的价值......
- 【idea】查询字段使用位置
猜你喜欢

Docuware mobile labor solution can help you build a new productivity model: anytime, anywhere, any device

Hilbert 变换与瞬时频率

Summary of process and thread knowledge points 1

18张图,直观理解神经网络、流形和拓扑

一篇万字博文带你入坑爬虫这条不归路 【万字图文】

18 diagrams, intuitive understanding of neural networks, manifolds and topologies

Flask reports an error: pymysq1.err OperationalError:(1054, “Unknown column ‘None‘ in ‘field list‘“)

【SQL之降龙十八掌】01——亢龙有悔:入门10题

图扑软件亮相 2022 福州数博会,携手共创数字新时代

Google play APK uploads other international app stores
随机推荐
Date conversion EEE MMM DD hh:mm:ss zzz YYYY
Writing assignment 1
C语言300行代码实现扫雷(可展开+可标记+可更改困难级别)
Flink SQL Hudi actual combat
Intel introduces you to visual recognition -- openvino
The digitalization of the consumer industry is upgraded to "rigid demand", and weiit's new retail SaaS empowers enterprises!
Summary of process and thread knowledge points 1
Google play APK uploads other international app stores
System Verilog common syntax
Recursion and divide and conquer
How to carry out engineering implementation of DDD Domain Driven Design
Rewriting method set
Docuware mobile labor solution can help you build a new productivity model: anytime, anywhere, any device
【mysql】多指标历史累计去重问题
Dart array, map, type judgment, conditional judgment operator, type conversion
Brushless DC motor controller (how much is the hall charge for changing the motor)
Common functions and usage of numpy
Digital currency of quantitative transactions - generate foot print factor data
DVWA之SQL注入
一篇万字博文带你入坑爬虫这条不归路 【万字图文】