【发布时间】:2014-08-29 19:15:20
【问题描述】:
我从事 Clojure 项目已有一段时间了,想知道如何在单击提交按钮后将用户从一个页面导航到另一个页面。 代码如下:
(defn view-film-input []
(view-layout
[:body {:style "background-color: #F2FB78"}
[:h2 "Add new film"]
(form-to [:post "/addfilm" ]
(label "movname" "Film title: ")
(text-field :txtname) [:br]
(label "prname" "Producer name: ")
(text-field :txtprname) [:br]
(label "location" "File location: ")
(text-field :txtlocation)[:br]
(label "duration" "Duration(minutes): ")
(text-field :txtduration)[:br]
(submit-button "Save"))]))
现在,这可行,但我想将用户导航到相同的“添加新电影”页面,或者在单击“保存”按钮后刷新表单,而不是只显示一个空白页面。
这是 GET\POST 部分:
(GET "/addfilm" [] (view-film-input))
(POST "/addfilm" [txtname txtprname txtlocation txtduration]
(insert-flick txtname txtprname txtlocation txtduration 90) )
提前致谢!
【问题讨论】:
-
我认为这是组合。您的视图需要返回响应。
insert-flick返回什么? -
它在另一个类中定义,该类管理数据库。将新电影添加到表中,使用 txtname、txtprname、txtlocation 和 txtduration 作为属性
标签: forms post clojure get submit-button