在IDEA运行中出现http:localhost:8080 是什么情况

2025-03-04 14:07:10
推荐回答(2个)
回答1:

【我的解决】
经反复检查,设置CATALINA_HOME也没用。突然想起自己之前改过hosts文件。立马改过来试试!!
注释掉这[127.0.0.1 localhost]一行之后,打开浏览试试。好使!能正常访问了。
但很快又碰到了一个问题,使用localhost可以访问,但使用127.0.0.1无法正常访问。于是Google,得到解决办法:
在server.xml中的

maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />

末尾添加 address="0.0.0.0" 即可解决。据说原因是因为:tomcat5默认以ipv6的格式来解析地址,添加此属性,告知其使用Ipv4格式解析地址。

maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" address="0.0.0.0"/>

至此,突然明白了,为什么在hosts文件中添加了[127.0.0.1 localhost]行后无法正常访问tomcat了,因为comcat不能正常解析127.0.0.1。于是重新在hosts中写下:127.0.0.1 localhost。启动,访问,果然好使。也就是tomcat在win7下(或者说我机子上的环境)默认ipv6,需要添加address="0.0.0.0"这么一个属性即可。

回答2:

应该是:http://localhost:8080吧