在 Grails 中获取当前页面的 URL [英] Getting the URL of the current page in Grails

查看:32
本文介绍了在 Grails 中获取当前页面的 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Grails 应用程序中,我想将用户从页面 A 发送到页面 B 上的表单,然后再次返回页面 A.

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.

为了跟踪要返回的 URL,我向页面 B 发送了一个returnPage"参数,其中包含要返回的页面的 URL(页面 A).

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).

目前我在页面 A 上使用 request.getRequestURL() 来检索页面的 URL.但是,我从 getRequestURL() 获得的 URL 与最终用户在他/她的地址栏中的 URL 不对应:

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?

推荐答案

答案是 request.forwardURI (详情在此).

这篇关于在 Grails 中获取当前页面的 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆