相关疑难解决方法(0)

如何在Java中解析JSON

我有以下JSON文本.如何可以解析它来获得pageName,pagePic,post_id,等?

{
   "pageInfo": {
         "pageName": "abc",
         "pagePic": "http://example.com/content.jpg"
    },
    "posts": [
         {
              "post_id": "123456789012_123456789012",
              "actor_id": "1234567890",
              "picOfPersonWhoPosted": "http://example.com/photo.jpg",
              "nameOfPersonWhoPosted": "Jane Doe",
              "message": "Sounds cool. Can't wait to see it!",
              "likesCount": "2",
              "comments": [],
              "timeOfPost": "1234567890"
         }
    ]
}
Run Code Online (Sandbox Code Playgroud)

java parsing json

971
推荐指数
26
解决办法
154万
查看次数

用Java获取"外部"IP地址

我不太确定如何获取机器的外部IP地址,因为网络外的计算机会看到它.

我的以下IPAddress类仅获取计算机的本地IP地址.

public class IPAddress {

    private InetAddress thisIp;

    private String thisIpAddress;

    private void setIpAdd() {
        try {
            InetAddress thisIp = InetAddress.getLocalHost();
            thisIpAddress = thisIp.getHostAddress().toString();
        } catch (Exception e) {
        }
    }

    protected String getIpAddress() {
        setIpAdd();
        return thisIpAddress;
    }
}
Run Code Online (Sandbox Code Playgroud)

java networking network-programming external ip-address

81
推荐指数
7
解决办法
10万
查看次数

无法在ServletRequest中获取客户端的IP

我正在尝试使用此方法获取远程IP:

String remoteAddress = ((ServletRequestAttributes) RequestContextHolder
                .currentRequestAttributes()).getRequest().getRemoteAddr();
Run Code Online (Sandbox Code Playgroud)

我在控制器中调用它,但它返回0:0:0:0:0:0:0:1.怎么了?

java ip spring servlets

2
推荐指数
1
解决办法
1999
查看次数

找出IP地址?

我在android上有一个应用程序,我正在连接到一个网站获取一些数据.是否有可能找到我实际连接的IP地址?我正在做:

HttpUriRequest request = new HttpGet("http://www.example.com");
DefaultHttpClient client = new DefaultHttpClient(params);
HttpResponse response = client.execute(request);

println("You connected to: " + response.getIpAddress(?));
Run Code Online (Sandbox Code Playgroud)

谢谢

java android

0
推荐指数
1
解决办法
262
查看次数