get localhost IP and hostName

request.getRemoteAddr()  // 本机IP
request.getRemoteHost()  //主机名称

 

 

java.net.InetAddress inetAddress = InetAddress.getLocalHost();
System.out.println(inetAddress.getHostAddress());
System.out.println(inetAddress.getHostName());

你可能感兴趣的:(java,.net)