我正在尝试使用play 2.10
渲染一个带有动作POST的表单@form(action = routes.Application.sentiment, args = 'id -> "helloform", 'method -> "POST")
此输出是(我在播放控制台中验证了这一点)
<form action="/sentiment" method="GET" id="helloform" method="POST">
这在浏览器中的最终效果是它最终忽略了第二个方法属性。我究竟做错了什么?如何覆盖默认表单方法?
答案 0 :(得分:2)
@form
帮助器确定操作method
上的表单route
参数,因此要更改它,您应该更改路径
/GET /sentiment controllers.Application.sentiment
到
/POST /sentiment controllers.Application.sentiment
(反之亦然)并且不要在视图中声明方法。
@form(action = routes.Application.sentiment, args = 'id -> "helloform")