/**@return*/public = Getrequest (). Getscheme () + "://" + Getrequest (). getServerName (); If(Getrequest (). Getserverport ()!=80) {URL+ = ":" + getrequest (). Getserverport (); } URL+ =getrequest (). Getcontextpath (); return URL;}
Js
/** * Get project and path, Http://localhost:8080/userCenter * @returns*/functionGetcontextpath () {//get the current URL, such as: http://localhost:8083/uimcardprj/share/meun.jsp varCurwwwpath=Window.document.location.href; //get the directories after the host address, such as: uimcardprj/share/meun.jsp varPathname=Window.document.location.pathname; varpos=Curwwwpath.indexof (pathName); //get host address, such as: http://localhost:8083 varLocalhostpaht=curwwwpath.substring (0, POS); //get the project name with "/", such as:/uimcardprj varProjectname=pathname.substring (0,PATHNAME.SUBSTR (1). IndexOf ("/") +1); return(localhostpaht+projectName);}
Java or JS get Project Access Path (domain name)