您的位置:首页 > 其它

项目路径解析

2013-07-15 08:41 155 查看
<%@ 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>
今天看到项目组每个页面都使用一个常量来定义项目名,以便于以后的移植,自己还是感觉这种方法更简单点于是记录下来。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: