1. 程式人生 > >Dorado7 AjaxAction Java獲取客戶端IP

Dorado7 AjaxAction Java獲取客戶端IP

@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();

}