动态的<base>

<%
    String basePath = request.getScheme()
            + "://"
            + request.getServerName()
            + ":"
            + request.getServerPort()
            + request.getContextPath()
            + "/";
%>

<!--写base标签,永远固定相对路径跳转的结果-->
<base href="<%=basePath%>">
getScheme

返回用于发出此请求的方案的名称,例如 httphttpsftp

不同方案具有不同的构造 URL 的规则,这一点已在 RFC 1738 中注明。

Returns the name of the scheme used to make this request, for example, http, https, or ftp.

Different schemes have different rules for constructing URLs, as noted in RFC 1738.

getServerName

返回请求被发送到的服务器的主机名。它是 Host 头值 ":"(如果有)之前的那部分的值,或者解析的服务器名称或服务器 IP 地址。

Returns the host name of the server to which the request was sent. It is the value of the part before ":" in the Host header value, if any, or the resolved server name, or the server IP address.

getServerPort

返回请求被发送到的端口号。它是 Host 头值 ":"(如果有)之后的那部分的值,或者接受客户端连接的服务器端口。

Returns the port number to which the request was sent. It is the value of the part after ":" in the Host header value, if any, or the server port where the client connection was accepted on.

getContextPath

返回请求 URI 指示请求上下文的那一部分。请求 URI 中首先出现的总是上下文路径。路径以 "/" 字符开头但不以 "/" 字符结束。对于默认(根)上下文中的 servlet,此方法返回 ""。容器不会解码此字符串。

Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "". The container does not decode this string.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值