How to get IP address of the client in Play! frame

2019-04-19 01:40发布

问题:

Possible Duplicate:
How to get the client 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.

回答1:

In Play 2.0's action you can get lot of data from Http.RequestHeader it can be fetched like this:

public static Result index() {
    String remote = request().remoteAddress();
    return ok(remote);
}