0

我用黑色。

有:

(defpage "/welcome" [] "Welcome to Noir!")

我确实使这两个 URL 都有效:

http://localhost:8080/welcome 
http://localhost:8080/welcome/

谢谢!

编辑:这是完整的答案。

server.clj,加起来(:use [ring.util.response :only [redirect]])

然后写 :

(defn wrap-slash 
  ""
  [handler]
  (fn [{:keys [uri] :as req}]
    (if (and (.endsWith uri "/") (not= uri "/"))
      (handler (assoc req :uri (.substring uri
                                0 (dec (count uri)))))
      (handler req))))

(server/add-middleware wrap-slash)
4

1 回答 1

1

Noir 的路由比其他一些更严格,所以看看这个问题,虽然有不同的标题,但问的是同样的事情。

于 2013-10-08T03:05:51.040 回答