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;
}