嘗試使用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"
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章