JSP中:
js中 :
java中:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
js中 :
function getRootPath(){
var strFullPath=window.document.location.href;
var strPath=window.document.location.pathname;
var postPath=strPath.substring(0,strPath.substr(1).indexOf('/')+1);
return postPath;
}
java中:
System.getProperty("web.root")
<context-param>
<span style="white-space:pre"> </span><param-name>webAppRootKey</param-name>
<param-value>web.root</param-value>
</context-param><pre name="code" class="html"><listener>
<listener-class>org.springframework.web.util.WebAppRootListener</listener-class>
</listener>