Dorado7 AjaxAction Java獲取客戶端IP
阿新 • • 發佈:2018-11-15
@Expose
@DataProvider
public String getCurrentEmployeeUserPrivilege(HttpServletRequest request,
HttpServletResponse response){
String ip = request.getHeader("x-forwarded-for");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
System.out.println("---Dorado7 AjaxAction獲取客戶端IP:" + ip);
return employeeDS.findEmployeeById(getCurrentEmployeeId()).getUserPrivilege();
}