How to get payload from a POST in Play 2.0

前端 未结 4 515
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-07 22:16

I\'m trying to implement a REST API with Play 2.0 (Scala) but I\'m getting stuck in POST method. How do I get the payload from Request object? I haven\'t find any documentation

4条回答
  •  日久生厌
    2021-02-07 22:45

    have a look at this article on playlatam

    also check this question on google list

    for java (with a param names java_name):

    String name = request().body().asFormUrlEncoded().get("java_name")[0];
    

    for scala (with a param names scala_name):

    def name = request.body.asFormUrlEncoded.get("scala_name")(0)
    

提交回复
热议问题