【发布时间】:2013-12-11 20:11:36
【问题描述】:
我有一个登录路由,应该将其输入参数作为 POST 变量传输。我已经这样定义了我的路线:
POST /v1/accounts/login controllers.v1.Accounts.login(username: String, password: String)
而我的控制器是这样的:
object Accounts extends Controller {
def login(username: String, password: String) = Action {
Ok("Foo " + username)
}
}
当我使用 Chromes Advance REST Client 测试此路由时,它仅适用于 GET 参数,如果我将其作为 application/x-www-form-urlencoded POST 表单数据发送则无效。
Play Framework documentation 从未真正提及 POST 参数,但也没有说它不起作用。
我认为如果我创建一个表单并将我的请求绑定到它可能会使其工作,但这似乎不必要地复杂。
真的没有办法使用路由文件绑定POST参数吗?
【问题讨论】:
-
我刚刚注意到这一点:
If the action method defines some parameters, all these parameter values will be searched for in the request URI, either extracted from the URI path itself, or from the query string所以我猜它确实不适用于 POST 参数。
标签: playframework playframework-2.2