1

这就是我定义我的应用程序的方式:

(defroutes index
   (GET "/" [] (main-page))
   (GET "/form" [] (render-page "Vote" (render-form)))
   (POST "/vote" {params :params} (post-vote params))
   (route/not-found "Page not found"))

(def app (site index))

(defservice app)

这里的站点用于捕获 :params,这是 compojure 0.6.0 中的一个新功能。但是,我在投票后得到了一张空地图。我想知道上面的代码有什么问题?

4

2 回答 2

2

如果您在谷歌应用引擎上运行它,我认为您不能使用(站点)便利功能,因为它包括使用谷歌不允许的 java 类的环的(wrap-multipart-params)功能。

除非您从表单上传文件,否则您可能不需要多部分参数。尝试从您的命名空间中删除 compojure.handler 并将您的 (def app (site index)) 替换为以下内容:

(def app
     (-> index
     (wrap-keyword-params)
     (wrap-nested-params)
     (wrap-params)))

干杯,科林

于 2011-02-17T08:56:27.580 回答
0

正如我在邮件列表中回复的那样,请确保您的表单确实在发送参数(html 表单中的输入控件必须具有 name="..." 属性)

于 2011-02-17T08:31:50.977 回答