切换城市功能没有实现么
来源:6-2 确定用户城市及状态
car
2017-10-26
private static String getRemoteIp(HttpServletRequest request) {
//x-forwarded-for:代表客户端,也就是HTTP的请求端真实的IP,只有在通过了HTTP代理或者负载均衡服务器时才会添加该项
String ip = request.getHeader("x-forwarded-for");
//Proxy-Client-IP和WL-Proxy-Client-IP: 只有在Apache(Weblogic Plug-In Enable)+WebLogic搭配下出现,其中“WL”就是WebLogic的缩写
//访问路径是:Client -> Apache WebServer + Weblogic http plugin -> Weblogic Instances
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();
}
// ip = "61.51.253.90";
// ip = "218.25.19.153";
//0:0:0:0:0:0:0:1: IPV6的形式,win7下可能会出现
return "0:0:0:0:0:0:0:1".equals(ip)? "127.0.0.1" : ip;
}始终返回127.0..0.1,用natapp映射外网地址也是127.0.0.1
写回答
1回答
-
局域网以及本机访问都是娶不到这个外网ip的,你就不要纠结了,想试的话用同一个交换机上的其他机器试试就ok,而且淘宝的这个ip访问很慢,且数据老是空,code返回错误码1,我换了新浪的
00
相似问题