一直用EL表达式${pageContext.request.contextPath}来传递应用名,在用到JS中时,很麻烦,虽然也可以用,但是加大了代码复杂度,因此这里推荐用JS获取应用名
function getContextPath() {
var contextPath = document.location.pathname;
var index =contextPath.substr(1).indexOf("/"); //这个地方可能有问题,要根据具体项目适当修改
contextPath = contextPath.substr(0,index+1);
delete index;
return contextPath;
}
转载于:https://my.oschina.net/hnqingping1255/blog/404082