使用Java HttpWebServer创建静态文件web服务器并设置子路径指向本地自定义目录

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

posted @ 2024-05-21 11:19  漠孤烟  阅读(3)  评论(0编辑  收藏  举报