首页 > 技术文章 > ${pageContext.request.contextPath}

zzzzw 2015-10-11 16:01 原文

${pageContext.request.contextPath}样是通过 get方法去取的,先pageContext.getRequest()得到HttpServletRequest对象,再调用 HttpServletRequest的getContextPath方法

作用是取出部署的应用程序名,这样不管如何部署,所用路径都是正确的。

El表达式的写法:${pageContext.request.contextPath}

jsp的写法:<%=request.getContextPath()%>

推荐阅读