博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
web(获取路径的方法)
阅读量:4575 次
发布时间:2019-06-08

本文共 535 字,大约阅读时间需要 1 分钟。

String path = this.getServletContext().getRealPath("/"); String path2 = this.getClass().getClassLoader().getResource("/").getPath(); String path3 = Thread.currentThread().getContextClassLoader().getResource("/").getPath();

输出结果如下:

path:E:\apache-tomcat-8.5.23-windows-x64\apache-tomcat-8.5.23\webapps\

path2:/E:/apache-tomcat-8.5.23-windows-x64/apache-tomcat-8.5.23/webapps/WEB-INF/classes/
path3:/E:/apache-tomcat-8.5.23-windows-x64/apache-tomcat-8.5.23/webapps/WEB-INF/classes/

转载于:https://www.cnblogs.com/beibidewomen/p/7922853.html

你可能感兴趣的文章
Python 循环语句(while, for)
查看>>
深入理解JavaScript原型链
查看>>
LinearGradient类来实现图片的渐变效果
查看>>
Golang关键字—— if/else
查看>>
数据清洗
查看>>
PHP&MySQL(三)——数组
查看>>
各种语法解释及用法
查看>>
UVA 1388 Graveyard
查看>>
Eclipse使用技巧
查看>>
网络请求之get与post异步请求
查看>>
堆和栈的区别
查看>>
清理内存
查看>>
蓝桥杯之装箱问题
查看>>
Spark常用算子详解
查看>>
JAVA_桥接模式
查看>>
Android(java)学习笔记76:Handler用法总结 和 秒表案例
查看>>
C#畅谈“网络电视”
查看>>
解决Maximum execution time of 120 seconds exceeded
查看>>
20172328《程序设计与数据结构》第四周学习总结
查看>>
react-native ListView 性能问题
查看>>