在使用tomcat作为servlet容器时,
需要设置connector中的enableLookups="true",才能使用request.getRemoteHost() 获得域名。
在linux下可能获得市localhost.localdomain,这时在/etc/hosts中设置一个纸箱127.0.0.1的域名就可以了。
request.getRemoteHost() 获得域名
最新推荐文章于 2024-01-18 14:18:01 发布

在使用tomcat作为servlet容器时,
需要设置connector中的enableLookups="true",才能使用request.getRemoteHost() 获得域名。
在linux下可能获得市localhost.localdomain,这时在/etc/hosts中设置一个纸箱127.0.0.1的域名就可以了。