经过测试:
现在我想获得客户端电脑的名字?有什么好方法
request.getRemoteAddr(); 获得客户端的IP地址
request.getRemoteHost();也只是获取IP,跟getRemoteAddr()方法结果一样
官方API说这个方法是获取获得客户端电脑的名字,我测试没有获得过机器名称。
英语解释如下:
getRemoteHost
java.lang.String getRemoteHost()
Returns the fully qualified name of the client or the last proxy that sent the request. If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the dotted-string form of the IP address. For HTTP servlets, same as the value of the CGI variable REMOTE_HOST.
Returns:
a String containing the fully qualified name of the client
现在我想获得客户端电脑的名字?有什么好方法