1. 程式人生 > >獲取tomcat當前路徑

獲取tomcat當前路徑

預設路徑:如本機就是http://localhost:8080/你自己配置的tomcat
別人訪問你的專案:就是你的ip:埠/你自己配置的tomcat
function getRootPath()
{
    var pathName = window.location.pathname.substring(1);
var webName = pathName == '' ? '' : pathName.substring(0, pathName.indexOf('/'));
return window.location.protocol + '//' + window.location.host + '/'+ webName + '/'
; }