${pageContext.request.contextPath}是JSP取得絕對路徑的方法,等價於<%=request.getContextPath()%> 。也就是取出部署的應用程序名或者是當前的項目名稱
比如我的項目名稱是demo1在瀏覽器中輸入爲http://localhost:8080/demo1/a.jsp ${pageContext.request.contextPath}或<%=request.getContextPath()%>
取出來的就是/demo1, 而"/"代表的含義就是http://localhost:8080
故有時候項目中這樣寫${pageContext.request.contextPath}/a.jsp,這裏的${pageContext.request.contextPath}拿到的值就是:
/demo1