web前端获取项目绝对路径

jsp获取项目绝对路径:

<%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"

%>

js文件中获取项目绝对路径:

var protocol = location.protocol; //获取http或https

var host = window.location.host; //获取IP和端口号

var contextPath = window.location.pathname.split("/")[1]; //获取项目名

var basePath = protocol +"//"+host+"/"+contextPath;

springboot前端页面获取项目绝对路径:

 

 

你可能感兴趣的:(web)