我嘗試了各種入門例子定位的Compojure,我可以得到一個基本的Hello World示例的路線基本的HTML工作作爲這樣無法在類路徑
(ns hello-world
(:use compojure.core ring.adapter.jetty)
(:require [compojure.route :as route]))
(defroutes example
(GET "/" [] "<h1>Hello World Wide Web!</h1>"))
(run-jetty example {:port 8080})
但是,當我嘗試使用HTML傭工像這樣
(ns hello-world
(:use compojure ring.adapter.jetty)
(:require [compojure.route :as route]))
(defroutes example
(GET "/" []
(html [:h1 "Hello World"])))
(run-jetty example {:port 8080})
然後我收到以下錯誤
[空]例外在線程「主要」 java.io.FileNotFoundException:找不到compojure__init.cla ss或classpath上的compojure.clj:(core.clj:1)
可能是你提到(:使用compojure.core ring.adapter.jetty),而不是(:使用compojure ring.adapter.jetty)? – W55tKQbuRu28Q4xv 2010-05-26 04:29:32
intraweb中還有很多例子,包括(:使用compojure)。這似乎是Compojure 0.4之前的例子,如下所述。上面的問題仍然代表着仍然遵循這些例子的人。 – Xian 2010-05-27 11:45:27
我認爲你的第二個例子缺少「[]」。它應該是(GET「/」[] ... – 2010-05-31 21:39:12