String tomcatRoot = request.getSession().getServletContext().getRealPath("/");
可以获取到"%tomcat_root%\%web_app_name%\"的绝对路径
本文介绍了一种方法,通过Java代码片段从Tomcat服务器中获取当前Web应用程序的绝对路径。此方法对于需要知道文件系统中确切位置的应用场景非常有用。
String tomcatRoot = request.getSession().getServletContext().getRealPath("/");
可以获取到"%tomcat_root%\%web_app_name%\"的绝对路径
1136

被折叠的 条评论
为什么被折叠?