<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>域名路径解析</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
协议名 Scheme =<%=request.getScheme() %><br>
域名 serverName=<%=request.getServerName() %><br>
端口号 serverPort = <%=request.getServerPort() %><br>
项目相对路径 path= <%=path%><br>
项目绝对路径 BasePath= <%=basePath%> <br>
</body>
</html>
今天看到项目组每个页面都使用一个常量来定义项目名,以便于以后的移植,自己还是感觉这种方法更简单点于是记录下来。
项目路径解析
最新推荐文章于 2024-08-05 03:35:04 发布