InetAddress addr = InetAddress.getLocalHost(); String ip = addr.getHostAddress().toString();//获得本机IP //访问的server的ip是:System.out.println("访问的ip是:" + ip); //访问者的ip是:System.out.println("ip是:" + request.getRemoteAddr());