天天看點

java如何擷取目前機器ip和容器port

擷取目前機器ip:

private static String getIpAddress() throws UnknownHostException {   
	InetAddress address = InetAddress.getLocalHost();   
	return address.getHostAddress();  
}
           

擷取容器port:

String port = String.valueOf(request.getLocalPort());