gpt4 book ai didi

scala - Play 2.0 : Optional list in query

转载 作者:行者123 更新时间:2023-12-04 11:56:27 24 4
gpt4 key购买 nike

我正在尝试使用可选列表作为查询参数定义路由

GET /places controllers.Application.query(filter: Option[Seq[Int]])

但收到此错误
conf/routes - PlayException: Compilation error [`)' expected but `]' found]

我知道 Play 2 handle Option很好,我希望它通过 Seq到我的自定义 QueryStringBindable ,如何实现这一点?

最佳答案

Play 2.0.2 路由解析器似乎不支持嵌套类型参数。我找到了解决方法,我为 Seq[Int] 定义了别名:

type IntSeq = Seq[Int]

并使用它代替原始类型:
GET /places controllers.Application.query(filter: Option[IntSeq])

现在它按预期工作。

关于scala - Play 2.0 : Optional list in query,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11358751/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com