请求url的相对路径研究

本文探讨了URL相对路径在不同场景下的解析规则,通过一系列测试案例,解析了如何正确使用“/”、“../”等符号来定位资源。重点分析了“../”返回上一层路径以及“/”代表根路径的原理,并指出“./”在某些情况下可能代表当前目录。
摘要由CSDN通过智能技术生成

 

 

 

struts_hdlogin.xml :

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
 <package name="hdlogin" extends="cx-struts-default" namespace="/hdlogin">
     <!-- 登录--> 
  <action name="login" class="org.hd.login.action.LoginAction" method="login">
     <result name="success">/jsp/layout/main.jsp</result>
     <result name="loginfail">/hdlogin.jsp</result>
  </action>
 </package>
</struts>


上面的请求返回的页面:

main.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
 String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>客户服务中心系统</title>
<link rel="shortcut icon" href="<%=path%>/resource/images/favicon.ico" type="image/x-icon"/>
</head>
<body>

<iframe src="layout/haha.jsp" width="100%" height="100%"
       name="maininner"  id="maininner"  frameborder="0" scrolling="hidden"></iframe>
      

</body>
</html>

 

工程的页面路径关系:


 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值