用play 2.0改变表单动作

时间:2013-02-11 14:47:07

标签: scala playframework-2.0

我正在尝试使用play 2.10

渲染一个带有动作POST的表单
@form(action = routes.Application.sentiment, args = 'id -> "helloform", 'method -> "POST")

此输出是(我在播放控制台中验证了这一点)

<form action="/sentiment" method="GET" id="helloform" method="POST">

这在浏览器中的最终效果是它最终忽略了第二个方法属性。我究竟做错了什么?如何覆盖默认表单方法?

1 个答案:

答案 0 :(得分:2)

@form帮助器确定操作method上的表单route参数,因此要更改它,您应该更改路径

/GET    /sentiment  controllers.Application.sentiment

/POST   /sentiment  controllers.Application.sentiment

(反之亦然)并且不要在视图中声明方法。

@form(action = routes.Application.sentiment, args = 'id -> "helloform")
相关问题