【发布时间】:2014-04-02 21:26:08
【问题描述】:
我正在设置一个使用 Ring 和 Compojure 构建路由和处理程序的 Web 应用程序。每次我尝试lein ring server 时都会收到 404 Not Found。但我应该看到
编辑 启动服务器后,IE 要求我打开或保存文件。但 Windows 无法读取 JSON 文件。
我的project.clj 看起来像
(defproject web-viz
:dependencies [[org.clojure/clojure "1.4.0"]
[ring/ring-core "1.1.7"]
[ring/ring-jetty-adapter "1.1.7"]
[compojure "1.1.3"]
[hiccup "1.0.2"]]
:plugins [[lein-ring "0.8.3"]]
:ring {:handler web-viz.web/app})
在 src 里面我有一个文件 web.clj
(ns web-viz.web
(:require [compojure.route :as route]
[compojure.handler :as handler]
[clojure.string :as str])
(:use compojure.core
ring.adapter.jetty
[ring.middleware.content-type :only
(wrap-content-type)]
[ring.middleware.file :only (wrap-file)]
[ring.middleware.file-info :only
(wrap-file-info)]
[ring.middleware.stacktrace :only
(wrap-stacktrace)]
[ring.util.response :only (redirect)]))
(defroutes site-routes
(GET "/" [] (redirect "/data/census-race.json"))
(route/resources "/")
(route/not-found "Page not found"))
(def app (-> (handler/site site-routes)
(wrap-file "resources")
(wrap-file-info)
(wrap-content-type)))
【问题讨论】:
-
在这里查看接受的答案stackoverflow.com/questions/2483771/…