As we know, direct access to the JSP EL expression in js is unable to obtain, if you want to get ${pageContext. Request. ContextPath} value, we can use the following two ways:
1, in the ${pageContext. Request. ContextPath} with single quotes, this is the most simple way
2. Create a form with type= “hidden”, for example:
<input name="rootUrl" id="rootUrl" type="hidden" value="${pageContext.request.contextPath}"/>
Then get the value of the form through the JS action:
//Get the project root path
var rootUrl = "";
$(function () {
rootUrl = $("#rootUrl").val();
})