2015-02-26 12:48

[Java] 取得 Client IP

  1. public String getClientIp(HttpServletRequest request){ 
  2.    String ip = request.getHeader("X-FORWARDED-FOR"); 
  3.  
  4.    if (ip == null) { 
  5.        ip = request.getRemoteAddr(); 
  6.    } 
  7.  
  8.    return ip; 
  9. } 

0 回應: