【发布时间】:2017-01-13 04:00:41
【问题描述】:
我在路由文件中有相同的路由,但它们的操作不同,如图所示
GET /counts controllers.Application.getAllCountsByFeature(features)
GET /counts controllers.Application.getAllCounts()
我将两条路线都称为
http://localhost:9000/segments/counts?features=feature_1,feature_2-feature_3
http://localhost:9000/segments/counts
但它不起作用。我想根据查询字符串识别调用哪个路由。如果提供了查询字符串,那么它应该命中 getAllCountsByFeature 方法等等。
有什么办法吗? 我正在使用 Play 2.5.9
【问题讨论】:
-
只用一个路由,在一个动作中做不同的查询
-
我建议使用 2 条路由或 1 条路由,并使用可选查询参数在控制器内部执行逻辑,如前所述
标签: scala playframework routes playframework-2.0