获取服务器相关信息

  InetAddress address = InetAddress.getLocalHost();
      System.out.println(address.getHostName());//主机名
      System.out.println(address.getCanonicalHostName());//主机别名
      System.out.println(address.getHostAddress());//获取IP地址
      System.out.println("===============");
      String severaddress = "http://" + request.getServerName() + ":" + request.getServerPort();
      System.out.println(severaddress);

你可能感兴趣的:(获取服务器相关信息)