当前位置:网站首页>相对路径和绝对路径
相对路径和绝对路径
2022-07-28 05:25:00 【wr_01】
斜杠和点表示相对路径和绝对路径
绝对路径:是从盘符开始的路径
相对路径:是从当前路径开始的路径
/是根目录(在Javaweb中可以结合项目内部的绝对路径作为相对路径使用)
./是当前目录(或开头什么都不写)
“…/”来表示上一级目录,
绝对路径
JavaWeb中的相对路径
相对路径又分为以斜杆开头的路径和不以斜杆开头的路径
- 以斜杆开头的路径:基准路径(根路径)的相对路径
- 不以斜杆开头的路径:当前目录的相对路径
根据路径所在文件所处位置的不同,分为两种:前台路径与后台路径。
A、 前台基准路径
所谓前台路径是指,由浏览器解析执行的代码中所包含的路径。
例如,html、css、js中的路径,及 jsp 中静态部分的路径。
像 html 及 jsp 中的静态部分中的<img src=" "/>、<a href=" "></a>、<form action=" "></form>等;像 css 中的 background:img("")等;像 js 中的window.location.href=" "等,都属于前台路径。
前台路径的参照路径是 Web 服务器的根路径,即 http://127.0.0.1:8080/
B、 后台基准路径
所谓后台路径是指,由服务器解析执行的代码及文件中所包含的路径。
例如,java 代码中的路径、jsp 文件动态部分(java 代码块)中的路径、xml 文件中的路径(xml 文件是要被java 代码加载入内存,并由 java 代码解析的)等。
后台路径的参照路径是 Web 应用的根路径。如 http://127.0.0.1:8080/primary/ (primary是Web应用的项目名)
HTML和JSP相对路径的基准区别
在默认的HTML页面和JSP页面中相对路径的基准是不一样的。
在HTML中base标签用来知道相对路径的基准(默认的HTML页面没有base标签,此时相对路径就是相对当前页面的路径)
在jsp中自动给我们加了一个base标签并且指定基准是项目路径,所以我们无论在哪级目录中写的相对路径都是基于项目路径的。
边栏推荐
- Perl入门学习(九)引用
- 雷达成像 Matlab 仿真 3 —— 多目标检测
- Random life-1
- The short jumper dsx-8000 test is normal, but the dsx-5000 test has no length display?
- 论文神器 VS Code + LaTex + LaTex Workshop
- Esxi on arm 10/22 update
- Trouble encountered in cable testing -- a case study of a manufacturer?
- MFC 使用控制台打印程序信息
- Mae mask self encoding is scalable learning
- Cautious speculation about fusion on Apple silicon
猜你喜欢

OpenGL快速配置方法

Systemmediasize startup option added in esxi 7.0 update 1C

Word邮件合并功能详解:合并后生成多个word文档,删除空白页

set_false_path

PyTorch 学习笔记 3 —— DATASETS & DATALOADERS & TRANSFORMS

clickhouse聚合之探索聚合内部机制

ConNeXt

Measure computer battery capacity

Photovoltaic power generation system MPPT maximum power point tracking

Selection of PLC
随机推荐
ICC2使用report_placement检查floorplan
Perl introductory learning (VIII) subroutine
EMC experiment practical case ESD electrostatic experiment
Bag of tricks training convolution network skills
Shuffle Net_ v1-shuffle_ v2
Matlab 信号处理
What is the AEM testpro cv100 and fluke dsx-8000 of category 8 network cable tester?
Fluke dtx-sfm2 single mode module of a company in Hangzhou - repair case
Pytorch learning notes 2 - about tensor
How can fluke dsx2-5000 and dsx2-8000 modules find the calibration expiration date?
An example of bill printing
For a large amount of data, matlab generates Excel files and typesetting processing source code
Bert bidirectional encoder based on transformer
Vs code basic configuration and beautification
ConNeXt
What about the insufficient memory of Clickhouse aggregation? Then improve the polymerization performance
EfficientNET_ V1
Analysis of MOSFET damage at the moment of power failure of isolated power supply
Hugging face 的问题记录 I
I heard that you are also practicing when I interviewed several junior interns.