1. request.getContextPath();在普通的java代码中用,当然也可以在jsp中用:<% String contextPath = request.getContextPath(); %>
2. ${pageContext.request.contextPath} jsp中el表达式,在jsp页面中用;
当在webapps中部署war包为:ROOT.war时,这时上下文路径为默认的:空字符串
当在webapps中部署war包为:platform.war时,这时上下文路径为:/platform
request.getContextPath();与${pageContext.request.contextPath}
原文:http://www.cnblogs.com/wenlj/p/5980189.html