Reputation: 1812
I am trying to access List[String] in controller so I write the code: My View is
@(path:List[String])
...
<button type=submit id=imgButton><a href="@routes.Application.confirmDelete(path)">Delete</a></button>
My routes is
GET /confirmDelete/:path controllers.Application.confirmDelete(path:List[String])
My controller is:
def confirmDelete(path:List[String])=Action{
Ok("deleted "+path);
}
But it gives me error as
No URL path binder found for type List[String]. Try to implement an implicit PathBindable for this type.
Upvotes: 2
Views: 883
Reputation: 1722
The error here is absolute clear. Play does not have any idea how to serialize List[String]
to and from uri. You can implement implicit PathBindable
conversion for List[String]
or submit this list as coma separated String
and build List[String]
on controllers side from String
parameter.
Documentation about PathBindable
- http://www.playframework.com/documentation/api/2.1.x/scala/index.html#play.api.mvc.PathBindable
Also you may check here for second solution - Play framework 2: Use Array[String] in route
Upvotes: 5