码迷,mamicode.com
首页 > 其他好文 > 详细

开发问题解决志

时间:2014-05-07 19:02:49      阅读:261      评论:0      收藏:0      [点我收藏+]

标签:code   get   2014   c   cti   for   

2014.5.5

     获取客户端真实ip地址出现问题,解答如下:

    

When you have NAT (Network Address Translation) device before your servlet container request.getRemoteAddr() returns the address of NAT , since it initiate a new connection.

To solve your problem you should configure you NAT to send in a header the IP of the original client. Then, to take the header from the request. In case you configure in NAT X-Forwarded-For header use this code: request.getHeader("X-Forwarded-For")

You function is correct, you can use it when you configure NAT.

 

   

开发问题解决志,布布扣,bubuko.com

开发问题解决志

标签:code   get   2014   c   cti   for   

原文地址:http://www.cnblogs.com/elearn007/p/3709819.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!