在我的 playframework 应用程序中,我想做一个简单的 Post 请求。
所以我在我的路线中定义了这个:
POST /printName @controllers.Index.printName()
就像我在scala中做的一样。
然后我有以下控制器功能:
public Result printName(Http.Request request) {
JsonNode json = request.body().asJson();
return ok("Got name: " + json.get("name").asText());
}
所以现在编译器返回:
类索引中的方法 printName 缺少参数;如果您想将其视为部分应用的函数,请使用 `_' 遵循此方法
当我像这样在路由中添加参数时:
POST /printName @controllers.Index.printName(request: Request)
然后我得到了这个错误
未找到:类型请求
怎么会是正确的?示例来自 Playframework 页面:https ://www.playframework.com/documentation/2.7.x/JavaBodyParsers#The-default-body-parser
提前致谢。
侃侃尔雅
相关分类