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

如果tomcat运行在IPV6启用的服务器环境中,比如windows server 2008,如果用IPV4的地址去访问8080端口,连接将会失败。即使在hosts文件中配置了:: localhost127.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 likeport="8080" address="0.0.0.0" maxHttpHeaderSize="8192").Restart Tomcat and you should be good to go.即在端口配置项中,添加address="0.0.0.0"
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章