${pageContext.request.contextPath}

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

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

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

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

时间: 2024-08-27 21:06:11