java webapps路径_java 获取服务器端的webapps路径 | 学步园
/**
* 獲取服務器端的webapps路徑
* @return
*/
public String findServerPath(){
String classPath = this.getClass().getClassLoader().getResource("/").getPath();
try {
classPath =URLDecoder.decode(classPath, "gb2312");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String[] strPath = classPath.split("/");
String path = "";
for(int i = 0;i < strPath.length ; i++){
if(i > 0 && i <= 3){
path = path + strPath[i]+"/";
}
}
return path;
}
備注:String filePath = System.getProperty("user.dir")+File.separator+"src"+File.separator+"main"+File.separator+"webapp"+File.separator+"downloads"+File.separator;
總結
以上是生活随笔為你收集整理的java webapps路径_java 获取服务器端的webapps路径 | 学步园的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java gui 组件_Java GUI
- 下一篇: java打印6个偶数_Java编写一个应