Play Framework 2.0 quicktip: ¿cómo obtener un valor POST desde un controller?

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:

Play Framework Latam Blog:

Play Framework Google Groups:



One response to this post.

  1. 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…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: