14 lines
353 B
Java
14 lines
353 B
Java
package ru.ulstu;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
public class HttpUtils {
|
|
public static String getUserIp(HttpServletRequest request) {
|
|
String xfHeader = request.getHeader("X-Forwarded-For");
|
|
if (xfHeader == null) {
|
|
return request.getRemoteAddr();
|
|
}
|
|
return xfHeader.split(",")[0];
|
|
}
|
|
}
|