尝试使用request.getRemoteAddr()时获得ipv6地址:0.0.0.0.0.0.0.1的解决方法

如果tomcat运行在IPV6启用的服务器环境中,比如windows server 2008,如果用IPV4的地址去访问8080端口,连接将会失败。 即使在hosts文件中配置了 :: localhost 127.0.0.1 localhost 也是没有效果的。因为这是tomcat的问题,我们需要在tomcat目录下,将server.xml中的address指定为使用IPV4, 详细配置可以参考如下 I found that there was a bug with Tomcat 5 running on Windows server 2008 64 bit. It attempts to use IPv6 over the default IPv4. To resolve it, open up the Server.xml file and search for "<Connector". The top Connector will have the port that you're trying to communicate through, in my case 8080. In between port="8080" maxHttpHeaderSize="8192" type address="0.0.0.0" (Line will look like port="8080" address="0.0.0.0" maxHttpHeaderSize="8192"). Restart Tomcat and you should be good to go. 即在端口配置项中,添加address="0.0.0.0"
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值