在播放框架中访问 List[String] 时出错

Pra*_*rat 2 scala list playframework-2.0

我试图访问控制器中的 List[String] 所以我写了代码:我的视图是

@(path:List[String])
   ...
    <button type=submit id=imgButton><a href="@routes.Application.confirmDelete(path)">Delete</a></button>
Run Code Online (Sandbox Code Playgroud)

我的路线是

   GET     /confirmDelete/:path      controllers.Application.confirmDelete(path:List[String])
Run Code Online (Sandbox Code Playgroud)

我的控制器是:

def confirmDelete(path:List[String])=Action{
     Ok("deleted "+path);
     }
Run Code Online (Sandbox Code Playgroud)

但它给了我错误

   No URL path binder found for type List[String]. Try to implement an implicit PathBindable for this type.
Run Code Online (Sandbox Code Playgroud)

1es*_*sha 5

这里的错误是绝对清楚的。Play 不知道如何List[String]与 uri进行序列化。您可以实现隐式PathBindable转换List[String]或将此列表作为昏迷分隔提交,StringList[String]在控制器端从String参数构建。

关于文档PathBindable- http://www.playframework.com/documentation/api/2.1.x/scala/index.html#play.api.mvc.PathBindable

您也可以在这里查看第二个解决方案 - Play framework 2: Use Array[String] in route