<%
String path = request.getContextPath()
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<script type="text/javascript" src="js/jquery/jquery-1.8.1.min.js"></script>
<body>
</body>
<!-- 通过hashemian.com查询本机IP -->
<script type="text/javascript" src="http://scripts.hashemian.com/js/visitorIPHOST.js.php">
</script>
<script type="text/javascript">
var data = $("td:parent")[0].lastChild.data
var ip = data.substring(6,data.length)
alert(ip)
</script>
</html>
os.networkInterfaces()参考这里:http://nodejs.org/api/os.html#os_os_networkinterfaces
Get a list of network interfaces:
{ lo0:
[ { address: '::1', family: 'IPv6', internal: true },
{ address: 'fe80::1', family: 'IPv6', internal: true },
{ address: '127.0.0.1', family: 'IPv4', internal: true } ],
en1:
[ { address: 'fe80::cabc:c8ff:feef:f996', family: 'IPv6',
internal: false },
{ address: '10.0.1.123', family: 'IPv4', internal: false } ],
vmnet1: [ { address: '10.99.99.254', family: 'IPv4', internal: false } ],
vmnet8: [ { address: '10.88.88.1', family: 'IPv4', internal: false } ],
ppp0: [ { address: '10.2.0.231', family: 'IPv4', internal: false } ] }