关于${pageContext.request.contextPath}的理解

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

    • 也就是取出部署的 应用程序名 或者是 当前的项目名称
  • 比如我的项目名称是 demo1 在浏览器中输入为:http://localhost:8080/demo1/a.jsp

    • ${pageContext.request.contextPath} 取出来的就是 /demo1 ,而 "/" 代表的含义就是 http://localhost:8080
    • 故有时候项目中这样写 ${pageContext.request.contextPath}/a.jsp

原文:https://www.cnblogs.com/zshibo/p/8011514.html

posted @ 2021-03-03 18:41    阅读(86)  评论(0)    收藏  举报