在Application中:
System.getProperty("user.dir")
在Servlet中:
ServletContext servletContext = config.getServletContext();
String rootPath = servletContext.getRealPath("/");
在JSP中:
application.getRealPath("")
System.getProperty("user.dir")
在Servlet中:
ServletContext servletContext = config.getServletContext();
String rootPath = servletContext.getRealPath("/");
在JSP中:
application.getRealPath("")
本文介绍了在不同Java环境中获取应用程序根目录的方法,包括Application、Servlet及JSP等场景下的具体实现方式。
1118

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



