JS获取项目根目录

function getRootPath(){
    //获取当前网址,如: http://localhost:8088/test/test.jsp
    var curPath=window.document.location.href;
    //获取主机地址之后的目录,如: test/test.jsp
    var pathName=window.document.location.pathname;
    var pos=curPath.indexOf(pathName);
    //获取主机地址,如: http://localhost:8088
    var localhostPaht=curPath.substring(0,pos);
    //获取带"/"的项目名,如:/test
    var projectName=pathName.substring(0,pathName.substr(1).indexOf(‘/‘)+1);
    return(localhostPaht+projectName);
}
时间: 2024-08-19 11:28:31

JS获取项目根目录的相关文章

js获取项目根目录的方法

getRootPath = function(){ //获取当前网址,如: http://localhost:8080/ems/Pages/Basic/Person.jsp var curWwwPath = window.document.location.href; //获取主机地址之后的目录,如: /ems/Pages/Basic/Person.jsp var pathName = window.document.location.pathname; var pos = curWwwPath

js获取网站根目录

<script type="text/javascript"> function getRootPath() { var strFullPath = window.document.location.href; var strPath = window.document.location.pathname; var pos = strFullPath.indexOf(strPath); var prePath = strFullPath.substring(0, pos);

js获取项目根路径

1 //js获取项目根路径,如: http://localhost:8083/uimcardprj 2 function getRootPath(){ 3 //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp 4 var curWwwPath=window.document.location.href; 5 //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp 6 var pathName=wind

java 或者 js 获取项目访问路径(域名)

/** * 获得站点url * @return */ public String getWebUrl(){ String url = getRequest().getScheme() + "://" + getRequest().getServerName(); if(getRequest().getServerPort()!=80){ url+= ":" + getRequest().getServerPort(); } url+=getRequest().get

c# 获取项目根目录方法

编写程序的时候,经常需要用的项目根目录.自己总结如下 1.取得控制台应用程序的根目录方法     方法1.Environment.CurrentDirectory 取得或设置当前工作目录的完整限定路径     方法2.AppDomain.CurrentDomain.BaseDirectory 获取基目录,它由程序集冲突解决程序用来探测程序集 2.取得Web应用程序的根目录方法     方法1.HttpRuntime.AppDomainAppPath.ToString();//获取承载在当前应用程

js获取当前根目录的方法

function getRootPath_web() { //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp var curWwwPath = window.document.location.href; //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp var pathName = window.document.location.pathname; var pos = curWwwPath

SpringMVC中Freemarker获取项目根目录

https://blog.csdn.net/whatlookingfor/article/details/51538995 在SpringMVC框架中使用Freemarker试图时,要获取根路径的方式如下: <!-- FreeMarker视图解析 如返回userinfo..在这里配置后缀名ftl和视图解析器.. --> <bean id="viewResolverFtl" class="org.springframework.web.servlet.view

获取项目根目录(非tomact)

String path; public void main(String[] args) { File file=new File(""); path=file.getAbsolutePath(); syso(path); } 结果: D:\svnout\borncrm-biz

weiapi 获取项目根目录

无法使用: Server.Map("~"); Server.Map("~/"); Server.Map("./"); Server.Map("."); 正确方式: var serverFile = System.Web.Hosting.HostingEnvironment.MapPath("~/");