在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里用System.getProperty(\user.dir\);在Servlet中通过ServletContext获取根路径;在jsp中使用application.getRealPath(\\)。
1116

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



