java 如何获取以前的网址?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6994936/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 18:11:26  来源:igfitidea点击:

How to get previous URL?

javajsf

提问by Johny T Koshy

I need the URL from which my web app is called. For eg:- If there is a link to my site foo.com from stackoverflow.com, I need the stackoverflow link in web app(managed bean).

我需要从中调用我的网络应用程序的 URL。例如:- 如果有一个从 stackoverflow.com 到我的站点 foo.com 的链接,我需要 web 应用程序(托管 bean)中的 stackoverflow 链接。

All helps appreciated, thanks.

所有帮助表示赞赏,谢谢。

回答by nfechner

Not always filled, but you can use:

并不总是填满,但您可以使用:

HttpServletRequest.getHeader("Referer");

Note: The spelling error is on purpose. For an explanation see here.

注意:拼写错误是故意的。有关解释,请参见此处

回答by Deepansh Gupta

By checking the HTTP Referrer you can see from which site the request for your site originated.

通过检查 HTTP Referrer,您可以看到对您站点的请求来自哪个站点。