获取计算机全名



String path = request.getContextPath(); //获取项目名

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";//获取全路径

//获取配置文件中的值

public String getUrl(){
  String strofficeApps=null ;
  Properties pro=new Properties();
  try {
   pro.load(getClass().getResourceAsStream("/spring-context.properties"));
   strofficeApps= pro.getProperty("strofficeapps");
  } catch (Exception e) {
   e.printStackTrace();
  }
  return strofficeApps;
 }

//获取计算机全名称

public String getServerName() {
  String name =null;
  InetAddress ServerIPaddress=null;
  try {
   ServerIPaddress=InetAddress.getLocalHost();
   name=ServerIPaddress.getCanonicalHostName();
  }
  catch (UnknownHostException e) {
   
  }
  return name;
 }

猜你喜欢

转载自blog.csdn.net/yingmengxuepingbao/article/details/51249325
今日推荐