使用Java HttpWebServer建立靜態檔案web伺服器並設定子路徑指向本地自定義目錄

漠孤烟發表於2024-05-21
httpServer.createContext("/abc", SimpleFileServer.createFileHandler(Path.of("D:\\my-abc")));
httpServer.createContext("/def", SimpleFileServer.createFileHandler(Path.of("D:\\test\\hello\\def")));

對應的訪問路徑分別是:
http://localhost:8080/abc
http://localhost:8080/def

相關文章