0

我正在尝试使用 Compojure 模仿 Wordpress 永久链接,但是为什么当我使用多个参数时找不到所有静态文件(css、js 和 img)?这是我的代码。

(defroutes approutes
  (GET "/" [] (posts-for-home))
  (GET "/:year/:month/:title" [year month title :as {uri :uri}] (single/tpl-single uri))
  (route/resources "/")
  (route/not-found "<h1>Page not found</h1>"))

(def app
  (handler/site approutes))

我在浏览器调试控制台中看到 css 是从而http://localhost:3000/2014/11/test/css/main.css不是http://localhost:3000/css/main.css. 然后我添加了一条测试路线,并且只使用了这样的参数:

(GET "/:testparameter" [testparameter] (single/tpl-single testparameter))

这条路线运行良好。当我访问http://localhost:3000/justfortest时,所有静态文件都是从根路径提供的。我应该怎么做才能解决这个多参数问题?提前感谢您的回答。

4

1 回答 1

3

最后我在替换<link rel="stylesheet" href="css/main.css"><link rel="stylesheet" href="/css/main.css">. 多么微不足道的问题,我一天都没注意到。洛好尴尬。

于 2014-11-10T11:52:52.607 回答