0

我想使用一个具有不同查询参数的url,这些参数将由不同的控制器处理:

GET /areas controllers.Application.getXTree(from: String, to: String)

GET /areas controllers.Application.getChildren(parentId:String)

现在我有第二条路线的错误:

对于请求 'GET /areas?parentId=f785d5cc-c8f7-4ddf-a611-757c8f91f536' [缺少参数:来自]

是否有可能做到这一点?

4

1 回答 1

0

不,这是不可能的:

许多路由可以匹配同一个请求。如果存在冲突,则使用第一条路线(按声明顺序)。路由优先级

尝试这个:

GET /areas/:from/:to controllers.Application.getXTree(from: String, to: String)

GET /areas/:parentId controllers.Application.getChildren(parentId:String)

你也可以使用

GET   /areas/*params          controllers.Application.xTreeOrChildren(params)

然后解析paramsApplication.xTreeOrChildren但我更喜欢第一个解决方案。

有关更多信息,请参阅ScalaRouting

于 2015-07-16T23:09:49.177 回答