【发布时间】:2017-07-11 03:34:49
【问题描述】:
我正在尝试使用 EL 在 jsp 页面中查找基本 url(主机、端口、上下文)。 我知道如何像这样在 servlet/jsp 上执行此操作
StringBuffer url = request.getRequestURL();
String uri = request.getRequestURI();
String ctx = request.getContextPath();
String base = url.substring(0, url.length() - uri.length() + ctx.length()) + "/";
我在网上搜索并在 stackoverflow https://stackoverflow.com/a/2898407/2515808 上找到了有关表达式语言的线索。
${pageContext.request.contextPath}
使用它我只能找出应用程序上下文路径。你能帮我找到主机和端口号吗?
谢谢
【问题讨论】:
-
下面的链接可能会有所帮助stackoverflow.com/questions/2989888/…