您的位置:首页 > 移动开发 > WebAPP

java 获取服务器端的webapps路径

2012-11-01 10:12 363 查看
/**
*获取服务器端的webapps路径
*@return
*/
publicStringfindServerPath(){
StringclassPath=this.getClass().getClassLoader().getResource("/").getPath();
try{
classPath=URLDecoder.decode(classPath,"gb2312");
}catch(UnsupportedEncodingExceptione){
e.printStackTrace();
}
String[]strPath=classPath.split("/");
Stringpath="";
for(inti=0;i<strPath.length;i++){
if(i>0&&i<=3){
path=path+strPath[i]+"/";
}
}
returnpath;
}
备注:StringfilePath=System.getProperty("user.dir")+File.separator+"src"+File.separator+"main"+File.separator+"webapp"+File.separator+"downloads"+File.separator;



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: