如何向 Grizzly 2.2 服务器添加静态 html 资源?我试过了
val server = GrizzlyHttpServerFactory.createHttpServer(uri, new ResourceConfig())
val statichandler = new StaticHttpHandler()
statichandler.addDocRoot("/webapp")
statichandler.start
server.getServerConfiguration.addHttpHandler(statichandler)
server.start
webapp 文件夹位于 Maven 项目中的 src/main/resource 内。
最佳答案
尝试:
val statichandler = new StaticHttpHandler(<path>, "/webapp");
server.getServerConfiguration.addHttpHandler(statichandler);
哪里<path>
是您希望提供服务的资源的绝对路径。
关于scala - Grizzly 2.2 添加静态资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12528324/