如何在Spring webapp的JSP中获取正确的当前URL [英] How to get correct current URL in JSP in Spring webapp
本文介绍了如何在Spring webapp的JSP中获取正确的当前URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在 Spring webapp 的 JSP 中获取正确的当前 URL.我正在尝试在 JSP 文件中使用以下片段:
I'm trying to get a correct current URL in JSP in Spring webapp. I'm trying to use the following fragment in the JSP file:
${pageContext.request.requestURL}
问题是返回的 URL 包含由 UrlBasedViewResolver 定义的前缀和后缀.例如正确的 URL 是:
The issue is that the returned URL contains prefix and suffix defined by UrlBasedViewResolver. For example the correct URL is:
但是返回的是:
http://localhost:8080/WEB-INF/jsp/page.jsp
推荐答案
最好的方法是使用 EL 像这样:
The best way would be to use EL like this:
${requestScope['javax.servlet.forward.request_uri']}
这篇关于如何在Spring webapp的JSP中获取正确的当前URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文