如下所示:
InetAddress addr = InetAddress.getLocalHost();
String ip = addr.getHostAddress().toString();//获得本机IP
//访问的server的ip是:System.out.println("访问的ip是:" + ip);
//访问者的ip是:System.out.println("ip是:" + request.getRemoteAddr());
时间: 2024-11-02 06:58:13