java 如何在 Play 中获取客户端的 IP 地址!框架2.0?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11721215/
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
How to get IP address of the client in Play! framework 2.0?
提问by Kris
Possible Duplicate:
How to get the client IP?
可能的重复:
如何获取客户端 IP?
How to get ip of the client in Play! framework 2.0? Is something implemented in Play? Any help, advices? I'm writing apps in Java.
如何在 Play 中获取客户端的 ip!框架2.0?在 Play 中实现了什么吗?任何帮助,建议?我正在用 Java 编写应用程序。
回答by biesior
In Play 2.0's action you can get lot of data from Http.RequestHeaderit can be fetched like this:
在 Play 2.0 的操作中,您可以从Http.RequestHeader获取大量数据,可以这样获取:
public static Result index() {
String remote = request().remoteAddress();
return ok(remote);
}