My Tomcat version is 6.0.
When using REQUEST.GETREMOTEADDR () to obtain an IP address under WIN7, the value that may be returned is not the IP we want, but rather the 0:0:0:0:0:0:0:1 of such a string value. This is the address of the IPv6 agreement, unfortunately we want to need is similar to 127.0.0.1 such IP address. In fact, this situation only occurs when your server and your client are the same machine, only in this case.
The reason is because C:\Windows\System32\drivers\etc\hosts this file, there are two lines in this file:
# 127.0.0.1 localhost
#:: 1 localhost
These two are actually one for IPV6, and one for IPV4. If it is the Win7 system, the default will be IPV6 so we get the value of this place is 0:0:0:0:0:0:0:1,XP does not appear this problem.
Method One (test effective, 360 will report domain name redirection, Firefox, ie not reported):
If the Win7 solution is to delete #::1 localhost this line of content, or to keep this behavior annotation state, and cancel #127.0.0.1 localhost The #号注释 of this line. Most articles on the web say that the approach here is to cancel this line of comment. If you simply uncomment, the IPV6 protocol is used to connect, which may cause your database connection to be wrong.
Of course, this place is mainly a problem that Win7 will encounter. Because only Win7 is used IPV6.
Method Two (untested):
Add in local tomcat parameter:-djava.net.preferipv4stack=true let tomcat only support ipV4.
Method Three (this method is the easiest and most effective and secure):
In the browser without locahost to access, but directly input 127.0.0.1 to access can also achieve the same effect