【发布时间】:2011-08-27 13:29:06
【问题描述】:
我在以下 Compojure 示例中获取表单参数时遇到问题:
(ns hello-world
(:use compojure.core, ring.adapter.jetty)
(:require [compojure.route :as route]))
(defn view-form []
(str "<html><head></head><body>"
"<form method=\"post\">"
"Title <input type=\"text\" name=\"title\"/>"
"<input type=\"submit\"/>"
"</form></body></html>"))
(defroutes main-routes
(GET "/" [] "Hello World")
(GET "/new" [] (view-form))
(POST "/new" {params :params} (prn "params:" params))
(route/not-found "Not Found"))
(run-jetty main-routes {:port 8088})
提交表单时输出总是
params: {}
我不知道为什么标题参数不在 params 映射中。
我正在使用 Compojure 0.6.2。
【问题讨论】: