优良作法是将您的所有链接如下
<a href="${pageContext.servletContext.contextPath}/othersite"> Other site </a>$ {pageContext.servletContext.contextPath}
始终为您提供应用程序根目录,当您开发use时
http://localhost:8080/myApp,您的应用程序根目录为 / myapp
,但是当您要将应用程序投入生产时,通常情况下,应用程序根目录将为 / ,使用 $ {pageContext
.servletContext.contextPath} ,以确保在两种情况下都可以使用



