Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play framework 2: Use Array[String] in route

I want to generate an url like this:

/photo?tags=tag1,tag2,tag3

routes file:

GET     /photo  controllers.Photos.list(tags:Array[String] ?= "")

I got this errors in play console:

No QueryString binder found for type Array[String]

What is the best way to achieve this ?

Thanks.

like image 719
mcarrolle Avatar asked Jul 02 '12 09:07

mcarrolle


1 Answers

play will bind to array's/lists when the values are in the query string or post data with the same name.

this also seems to work:

This route: http://localhost/controller/{id} 

This url: http://localhost/controller/1?id=2&id=3

Will bind to controller(int[] id) where id -> {1, 2, 3}

posting id=2&id=3 will also bind to an array.

reference: https://groups.google.com/forum/?fromgroups#!topic/play-framework/c5kB6wmcF8Q

like image 171
Ahmed Aswani Avatar answered Sep 19 '22 12:09

Ahmed Aswani