从 Compojure 提供静态文件

发布于 2024-12-27 10:11:35 字数 341 浏览 3 评论 0原文

我正在尝试创建一个可自动执行的应用程序,该应用程序将运行 jetty 和 Compojure web 应用程序。将部署应用程序的用户应该能够手动修改 css 文件和一些配置文件,因此打包为 WAR 对我来说不是一个解决方案。

我的想法是在一个目录中有一个可自执行的 JAR,并在其下有一个 webdata/static/css 目录。

但是,当使用以下路由时,不提供 css 目录中的文件:

(route/files "/static" {:root (str (System/getProperty "user.dir") "/webdata")})

有什么问题吗?

I'm trying to have a self-executable app that will runs jetty and a Compojure webapp. The user who will deploy the app should be able to modify manually the css files and some configurations files, so packaging as a WAR is not a solution for me.

My idea is to have a self-executable JAR in one directory and a webdata/static/css directory under it.

However when using the following route, the file in the css directory are not served:

(route/files "/static" {:root (str (System/getProperty "user.dir") "/webdata")})

What is the problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鸠魁 2025-01-03 10:11:35

好吧,我发现了错误,路径没有正确指定。此代码有效:

(route/files "/" {:root (str (System/getProperty "user.dir") "/webdata/public")})

项目的树结构如下所示:

standalone-jar.jar
webdata
    |_public
      |_css

Ok I found the error, the path wasn't specified correctly. This code works:

(route/files "/" {:root (str (System/getProperty "user.dir") "/webdata/public")})

The tree structure of the project is then like this:

standalone-jar.jar
webdata
    |_public
      |_css
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文