I have a route that is type "POST". I am sending post data to the page. How do I access that post data. For example, in PHP you use $_POST
How do I access the post data in scala and play framework?
I have a route that is type "POST". I am sending post data to the page. How do I access that post data. For example, in PHP you use $_POST
How do I access the post data in scala and play framework?
Here you've got good sample how it's done in Play:
https://github.com/playframework/Play20/blob/master/samples/scala/zentasks/app/controllers/Application.scala
It's described in the documentation of the forms submission
As of Play 2.1, there are two ways to get at POST parameters:
1) Declaring the body as form-urlencoded via an Action parser parameter, in which case the request.body is automatically converted into a Map[String, Seq[String]]:
2) By calling request.body.asFormUrlEncoded to get the Map[String, Seq[String]]:
Here you've got good sample how it's done in Play 2:
as @Marcus points out, bindFromRequest is the preferred approach. For simple one-off cases, however, a field
can be accessed via post'd form like so