从uberjar运行时,Ring的文件响应对我不起作用。我都试过了
(response/file-response "index.html" {:root "resources/public"})和
(response/response (clojure.java.io/as-file (clojure.java.io/resource "public/index.html")))如何在uberjar中"/“为index.html服务?
发布于 2013-09-18 15:29:55
您将需要使用ring.util.response/resource-response,它为类路径上找到的文件提供服务。假设您想要为您的überjar中的index.html目录中的resources文件提供服务,那么参数将与调用file-response中的参数几乎完全相同。
(response/resource-response "index.html" {:root "public"})它是"public"而不是"resources/public",因为resources是包括在überjar中的顶级目录之一,所以在顶层的类路径上可以找到public。(如果从文件系统运行而不是从überjar运行,则也是如此;路径需要相对于类路径上的某个顶级目录。)
https://stackoverflow.com/questions/18875117
复制相似问题