日期:2014-05-20  浏览次数:20837 次

ssh2 action中如何获取客户端的信息
ssh2 action中如何获取客户端的信息
电脑名称 使用 getRequest().getRemoteAddr();和getRequest().getRemoteHost();获取的均是IP地址
请问 用什么方法可以准确获取 客户端电脑名称

MAC 客户端物流地址用什么办法获取

------解决方案--------------------
头信息里面去找吧..
------解决方案--------------------
HttpServletRequestrequest= ServletActionContext.getRequest();
------解决方案--------------------
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.InetAddress;
/*
 * Created on 2006/8/1
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
/**
 * @author Administrator
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class GetMac {
private static String getMacOnWindow() {
String s = "";
try {
String s1 = "ipconfig /all";
Process process = Runtime.getRuntime().exec(s1);
BufferedReader bufferedreader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String nextLine;
for (String line = bufferedreader.readLine(); line != null; line = nextLine) {
nextLine = bufferedreader.readLine();
if (line.indexOf("Physical Address") <= 0) {
continue;
}
int i = line.indexOf("Physical Address") + 36;
s = line.substring(i);
break;
}
bufferedreader.close();
process.waitFor();
} catch (Exception exception) {
s = "";
}
return s.trim();
}
 public static void main(String[] args) {
//InetAddress.getLocalHost().getHostAddress();
try{
InetAddress.getLocalHost(); 
System.out.println("host name="+InetAddress.getLocalHost().getHostName());
System.out.println("ip ="+InetAddress.getLocalHost().getHostAddress());
}catch(Exception ex){
//
}
  
System.out.println("mac ="+GetMac.getMacOnWindow());
 }
}
------解决方案--------------------
貌似木有办法 你只能取到 出口端路由器的信息
------解决方案--------------------
局域网内访问 貌似是可以的