import java.net.*; public class Ipconfig{ public static void main(String[] arguments) throws Exception{ InetAddress ia = InetAddress.getLocalHost();//获取本地IP对象 System.out.println("MAC ......... "+getMACAddress(ia)); }
1.获取客户端IP地址 public String getIp(HttpServletRequest request) throws Exception { String ip = request.getHeader("X-Forwarded-For"); if (ip != null) { if (!ip.isEmpty() && !"unKnown".equalsIgnoreCase(ip)) { int index = ip.indexOf(&