8
我在Play中看到! 2.0有Http.Context.current() http://www.playframework.org/documentation/api/2.0/java/play/mvc/Http.Context.html#current()如何在Java Play 1.2.4中获取传入请求IP地址
但在Play! 1.2.4如何获取当前HTTP请求的IP地址?
谢谢。
我在Play中看到! 2.0有Http.Context.current() http://www.playframework.org/documentation/api/2.0/java/play/mvc/Http.Context.html#current()如何在Java Play 1.2.4中获取传入请求IP地址
但在Play! 1.2.4如何获取当前HTTP请求的IP地址?
谢谢。
如果您在控制器内,你可以做
request.remoteAddress;
否则,你需要做的
Http.Request.current.get().remoteAddress;
这是正确的,但如果你使用的是Apache,只要你想前端服务器查看request.headers.get(“x-forwarded-for”) – nylund 2012-10-11 09:51:43