Using play framework 2.0 in Java mode and I want to pass a list of strings to a Controller using the URL parameters.
Given a URL such as:
http://localhost:9000/echo?messages=hello&messages=world
I want to call my Controller method:
public static Result echo(List<String> messages){
return ok("Size: " + messages.size());
}
My routes file looks like this:
GET /echo controllers.Application.echo(messages: List[String])
But it doesn’t work. I get errors claiming there is no QueryString binder for List[String]. This doesn’t seem right to me as this was pretty standard functionality in the previous version. Does anybody know how I can pass a list of strings to the controller using a Java project?
For now you can retrieve them from the query string:
Update: A list binder has been added, so you can just write the following:
Be sure your route definition looks like the following: