获取网站根目录contPath
2018-02-23 10:08
239 查看
一、request.getContextPath()
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" perfix="c"%>
<c:set var="contPath" value="${pageContext.request.contextPath}"></c:set>
<head>
<% String contPath=request.getContextPath(); %>
</head>
二、function getContextPath()
function getContextPath(){
var pathName=document.location.pathname;
var index=pathName.substr(1).indexOf("/");
var result=pathName.substr(0,index+1);
return result;
}
var contPath=getContextPath();
三、赋值一个hidden的控件
<input type=“hidden” name=“contextPath” value=<%= request.getContextPath() %> >
然后js里面获取hidden 的值
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" perfix="c"%>
<c:set var="contPath" value="${pageContext.request.contextPath}"></c:set>
<head>
<% String contPath=request.getContextPath(); %>
</head>
二、function getContextPath()
function getContextPath(){
var pathName=document.location.pathname;
var index=pathName.substr(1).indexOf("/");
var result=pathName.substr(0,index+1);
return result;
}
var contPath=getContextPath();
三、赋值一个hidden的控件
<input type=“hidden” name=“contextPath” value=<%= request.getContextPath() %> >
然后js里面获取hidden 的值
相关文章推荐
- asp.net 获取网站根目录总结 Global.asax文件里获取获取网站根目录
- MVC三层,BLL层获取网站根目录
- java中EL表达式怎么获取网站的根目录
- php获取网站根目录(需要知道网站更目录文件夹名)
- asp.net 获取网站根目录
- 获取网站根目录C#
- ASP.NET编程获取网站根目录方法小结
- Asp.NET 获取网站根目录
- js获取网站根路径(站点及虚拟目录),获得网站的根目录或虚拟目录的根地址
- asp.net获取网站目录物理路径
- asp.net 获取网站根目录的方法
- php 获取网站根目录的写法
- JS 获取网站根目录 域名+站名
- jsp页面获取网站部署根目录的两个方法
- php获取网站根目录物理路径的几种方法(推荐)
- js获取网站根目录
- .net 获取网站根目录的方法
- asp.net中获取网站根目录和物理路径的方法
- asp.net 获取网站根目录
- C# 获取网站地址或网站虚拟目录