./和../以及/之间的区别

本文详细介绍了在Web应用中使用相对路径('./'、'..')与绝对路径('/')进行页面跳转的方法及其实现原理。通过具体实例展示了不同路径指定方式如何影响最终的URL构造。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

./ 当前目录

../ 父级目录

/ 根目录

1 ./ 当前目录

项目的根目录是http://localhost:8080/ServletPathDirectionDemo/

TestServlet.java位于servlet包下,访问地址是
http://localhost:8080/ServletPathDirectionDemo/servlet/TestServlet

在dopost方法中重定向:

 response.sendRedirect("./test.jsp");

则跳转到了:
http://localhost:8080/ServletPathDirectionDemo/servlet/test.jsp
./ 表示当前目录http://localhost:8080/ServletPathDirectionDemo/servlet/

2 ../ 父级目录
在dopost方法中重定向:

 response.sendRedirect("../test.jsp");

则跳转到了:
http://localhost:8080/ServletPathDirectionDemo/test.jsp
../ 表示当前目录的父级目录:
http://localhost:8080/ServletPathDirectionDemo/

3 / 根目录

在dopost方法中服务器内部跳转:

 //服务器内部跳转,这里的斜线表示项目的根目录
request.getRequestDispatcher("/test.jsp").forward(request, response);

则跳转到了:
http://localhost:8080/ServletPathDirectionDemo/test.jsp

采用gcc编译器Makefile,输出日志的106行输出如下: arm-none-eabi-gcc -DUIP_CONF_IPV6_RPL_LITE=1 -DNETSTACK_CONF_FRAMER=framer_802154 -DCONTIKI=1 -DCONTIKI_TARGET_PLATFORMCCT6=1 -DCONTIKI_TARGET_STRING=\"platformCCT6\" -DPROJECT_CONF_PATH=\"project-conf.h\" -I../../arch/cpu/arm/CMSIS/CMSIS/Core/Include -I../../arch/cpu/arm/CMSIS/Device/ARM/ARMCM0/Include -I../../arch/cpu/arm/stm32f030CCT6 -I../../arch/cpu/arm/stm32f030CCT6/Core/Inc -I../../arch/cpu/arm/stm32f030CCT6/Drivers/CMSIS/Core/Include -I../../arch/cpu/arm/stm32f030CCT6/Drivers/CMSIS/Include -I../../arch/cpu/arm/stm32f030CCT6/Drivers/CMSIS/Device/ST/STM32F0xx/Include -I../../arch/cpu/arm/stm32f030CCT6/Drivers/STM32F0xx_HAL_Driver/Inc -I../../arch/cpu/arm/stm32f030CCT6/Drivers/STM32F0xx_HAL_Driver/Inc/Legacy -DCMSIS_DEV_HDR=\"stm32f0xx.h\" -mcpu=cortex-m0 -mthumb -DUSE_HAL_DRIVER -DSTM32F030xC -I../../arch/cpu/arm/stm32f030CCT6/Core/Inc -I../../arch/cpu/arm/stm32f030CCT6/Drivers/STM32F0xx_HAL_Driver/Inc -I../../arch/cpu/arm/stm32f030CCT6/Drivers/STM32F0xx_HAL_Driver/Inc/Legacy -I../../arch/cpu/arm/stm32f030CCT6/Drivers/CMSIS/Device/ST/STM32F0xx/Include -I../../arch/cpu/arm/stm32f030CCT6/Drivers/CMSIS/Include -I../../arch/cpu/arm/stm32f030CCT6/Drivers/CMSIS/Core/Include -Og -Wall -fdata-sections -ffunction-sections -Wa,-a,-ad,-alms=build/startup_stm32f030xc.lst -g -gdwarf-2 -MMD -MP -MF"build/platformCCT6/obj/nullframer.d" -mthumb -mabi=aapcs -mlittle-endian -Wall -std=c11 -ffunction-sections -fdata-sections -fno-strict-aliasing -Werror -Os -ggdb -DMAC_CONF_WITH_CSMA=1 -DNETSTACK_CONF_WITH_IPV6=1 -DROUTING_CONF_RPL_LITE=1 -imacros ../../os/services/shell/module-macros.h -I. -I../../arch/platform/platformCCT6/. -I../../arch/cpu/arm/stm32f030CCT6/. -I../../arch/cpu/arm/stm32f030CCT6/Core -I../../arch/cpu/arm/stm32f030CCT6/Drivers -I../../arch/cpu/arm/stm32f030CCT6/Core/Inc -I../../arch/cpu/arm/stm32f030CCT6/Core/Src -I../../arch/cpu/arm/stm32f030CCT6/Drivers/STM32F0xx_HAL_Driver/Inc -I../../arch/cpu/arm/stm32f030CCT6/Drivers/STM32F0xx_HAL_Driver/Inc/Legacy -I../../arch/cpu/arm/stm32f030CCT6/Drivers/STM32F0xx_HAL_Driver/Src -I../../arch/cpu/arm/stm32f030CCT6/Drivers/CMSIS/Device/ST/STM32F0xx/Include -I../../arch/cpu/arm/stm32f030CCT6/Drivers/CMSIS/Include -I../../arch/cpu/arm/stm32f030CCT6/Drivers/CMSIS/Core/Include -I../../arch/cpu/arm/stm32f030CCT6/Drivers/CMSIS/Device/ARM/ARMCM0/Include -I../../arch/cpu/arm/stm32f030CCT6/../arm/CMSIS/CMSIS/Core/Include -I../../arch/cpu/arm/stm32f030CCT6/../arm/cortex-m -I../../arch/cpu/arm/stm32f030CCT6/../arm/. -I../../os/services -I../../os/services/shell -I../../os/services/shell/serial-shell -I../../os/services/shell/commands -I../../os/dev/nullradio -I../../os/dev/serial-line -I../../os/net/ipv6/uip-udp -I../../NETSTACK_CONF_WITH_IPV6=1 -I../../NETSTACK_CONF_FRAMER=framer_802154 -I../../NETSTACK_CONF_WITH_IPV6_ND=1 -I../../NETSTACK_CONF_WITH_IPV6_RPL=0 -I../../NETSTACK_CONF_WITH_IPV6_RPL_LITE=1 -I../../os -I../../arch -I../../os/sys -I../../os/lib -I../../os/dev -I../../os/net -I../../os/net/routing -I../../os/net/mac -I../../os/net/mac/framer -I../../os/storage -I../../os/services -I../../os/lib/newlib -I../../os/lib/dbg-io -I../../os/net/mac/csma -I../../os/net/ipv6 -I../../os/net/routing/rpl-lite -I../.. -MT build/platformCCT6/obj/nullframer.o -MMD -MP -MF build/platformCCT6/obj/.deps/nullframer.c.d -c ../../os/net/mac/framer/nullframer.c -o build/platformCCT6/obj/nullframer.o 你能发现是什么导致编译器坚持输出nullframer.o的?
最新发布
06-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

子林Android

感谢老板,老板大气!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值