34-java-獲取資源路徑
阿新 • • 發佈:2018-12-21
01.獲取路徑
02.獲取資源流
03.獲取路徑下所有資源的路徑
@Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { //得到有碟符的路徑 String path = getServletContext().getRealPath("/index.jsp"); System.out.println(path); //獲取路徑之後,建立輸入流物件 InputStream input = getServletContext().getResourceAsStream("/index.jsp"); //獲取當前路徑下所有資源的路徑 Set<String> paths = getServletContext().getResourcePaths("WEB-INF"); System.out.println(paths); }