ServletContext获取文件资源
ServletContext获取文件资源?
1)获取真实路径
String path = this.getServletContext().getRealPath("/index.jsp");
2)获取资源流
InputStream input = this.getServletContext().getResourceAsStream("/index.jsp");
3)获取指定目录下所有资源路径
Set<String> paths = this.getServletContext().getResourcePaths("/WEB-INF");
注意,本方法必须以“ / ”开头!!!
-----------------------------------------------------------------------------------------------------------