Clojure 为什么ring在这个响应中给了我错误?
下面是我的应用程序-Clojure 为什么ring在这个响应中给了我错误?,clojure,ring,Clojure,Ring,下面是我的应用程序- (ns mfaiz.routes (:use [net.cgrand.moustache :only [app]] [net.cgrand.enlive-html :only [deftemplate content]] [ring.util.response :only [response]])) (deftemplate reg "mfaiz/templates/reg.html" []) (def my-app (app
(ns mfaiz.routes
(:use [net.cgrand.moustache :only [app]]
[net.cgrand.enlive-html :only [deftemplate content]]
[ring.util.response :only [response]]))
(deftemplate reg "mfaiz/templates/reg.html" [])
(def my-app (app
["hi"] "Hello World!"
["reg"] (-> ((-> "reg" symbol resolve)) response constantly)
[&] "Nothing was found"))
我在这条路线上遇到了错误-
["reg"] (-> ((-> "reg" symbol resolve)) response constantly)
如果我直接评估上述路由,它将正常工作并返回html文件-
((-> "reg" symbol resolve))
如果我还将路由更改为直接调用模板函数,那么它也可以工作-
["reg"] (-> (reg) response constantly)
知道哪里出了问题吗?问题似乎是,当它在环下运行时,“reg”没有得到解决,因为它不是完全合格的。这取决于环服务器在哪个命名空间中启动。因此,使用完全限定名称将有效:
(>“mfaiz.routes/reg”符号解析)
请检查
解决
。它试图解析当前名称空间中的符号,即在*ns*
中。问题似乎是,当它在环下运行时,“reg”没有被解析,因为它不是完全限定的。这取决于环服务器在哪个命名空间中启动。因此,使用完全限定名称将有效:
(>“mfaiz.routes/reg”符号解析)
请检查
解决
。它尝试解析当前名称空间中的符号,即在*ns*
中尝试使用(>“mfaiz.routes/reg”符号解析)
@Ankur谢谢,这非常有效!Ankur当符号存在于ns中时,我为什么需要指定ns。此外,在repl中没有ns资格认证的情况下,评估是成功的,为什么会这样?您也可以将其作为答案发布,我将对其进行标记。尝试使用(>“mfaiz.routes/reg”符号解析)
@Ankur谢谢,这非常有效!Ankur当符号存在于ns中时,我为什么需要指定ns。此外,在repl中没有ns资格认证的情况下,评估是成功的,为什么?您也可以将其作为答案发布,我将对其进行标记。