我正在尝试访问控制器中的List [String],所以我编写代码: 我的观点是
@(path:List[String])
...
<button type=submit id=imgButton><a href="@routes.Application.confirmDelete(path)">Delete</a></button>
我的路线是
GET /confirmDelete/:path controllers.Application.confirmDelete(path:List[String])
我的控制器是:
def confirmDelete(path:List[String])=Action{
Ok("deleted "+path);
}
但它给我的错误是
No URL path binder found for type List[String]. Try to implement an implicit PathBindable for this type.
答案 0 :(得分:4)
这里的错误绝对清楚。 Play不知道如何将List[String]
序列化到uri和从uri序列化。您可以为PathBindable
实施隐式List[String]
转化,或者在String
参数的控制器端以逗号分隔List[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