Suena tonto, pero me llevó varios minutos y no lo encontré en la documentación online. Creo que es algo bastante común.
Quiero acceder a un valor POST simple desde un controller en Play Framework 2.0…
En este caso el atributo “filter”:
String filter = request().body().asFormUrlEncoded().get(“filter”)[0];
Eso es todo.
Tip Play Framework 2.0: how to get a single POST value?
Sounds silly, but I spent some minutes on it and couldn’t find anything in the online documentation. I think it’s quite common.
I want to get a single POST value from controller in Play Framework 2.0
In this case the attribute is called “filter”:
String filter = request (). Body (). AsFormUrlEncoded (). Get (“filter”) [0];
That’s it.
———————————————————–
Play Framework Main Site: http://www.playframework.org/
Play Framework Latam Blog: https://playlatam.wordpress.com/
Play Framework Google Groups:
- English: http://groups.google.com/group/play-framework
- Español: http://groups.google.com/group/play-latam
Posted by alangreid on 10 April, 2012 at 19:26
Another way I found is calling form().bindFromRequest().get(“firstName”) for instance. It was a nightmare to find and it’s really silly not just have a params() method that does the trick…