jsp中${pageContext.request.contextPath}的意思

${pageContext.request.contextPath}是JSP取得绝对路径的方法,等价于<%=request.getContextPath()%> 。

也就是取出部署的应用程序名或者是当前的项目名称

比如我的项目名称是demo1在浏览器中输入为http://localhost:8080/demo/test.jsp ${pageContext.request.contextPath}或<%=request.getContextPath()%>取出来的就是/demo,而"/"代表的含义就是http://localhost:8080

故有时候项目中这样写${pageContext.request.contextPath}/test.jsp

posted @ 2019-03-08 10:12  Samuel-Leung  阅读(920)  评论(0编辑  收藏  举报