展开全部请求客户端是不是用代理了?如果用了代理就不能这么获取了.publicstringgetipaddr(httpservletrequestrequest){stringip=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();}returnip;}