问题描述
在Grails应用程序中,我想从页面A发送用户,然后发送到页面B上的表单,然后再返回到页面A.到跟踪返回哪个网址我向页面B发送一个returnPage参数,其中包含要返回到网页的网址(页面A)。
目前我是使用页面A上的request.getRequestURL()来检索页面的URL。但是,我从getRequestURL()获得的URL与最终用户在他/她的地址栏中的URL不对应:
request.getRequestURL()==http:// localhost:8080 / something / WEB-INF / grails-app / views / layouts / main.gsp
地址栏中的URL ==http:/ / localhost:8080 / something / some / thing
如何获取最终用户 URL?
答案是 request.forwardURI
()。
In a Grails application I'd like to send a user from page A, then to a form on page B and then back to page A again.
To keep track of which URL to return to I send a "returnPage" parameter to page B containing the URL of page to return to (page A).
Currently I'm using request.getRequestURL() on page A to retrieve the page's URL. However, the URL I get from getRequestURL() does not correspond to the URL the end-user has in his/hers address bar:
request.getRequestURL() == "http://localhost:8080/something/WEB-INF/grails-app/views/layouts/main.gsp"
URL in address bar == "http://localhost:8080/something/some/thing"
How do I obtain the "end-user" URL?
The answer is request.forwardURI
(details here).
这篇关于在Grails中获取当前页面的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!