How do I set params for WS.post() in play 2.1 Java

后端 未结 7 1736
慢半拍i
慢半拍i 2020-12-09 20:43

I\'m trying to perform a post with play.api.libs.ws.WS but I can\'t figure out how to set the params, my code:

Promise promise = WS.url(Play.         


        
7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-09 21:46

    for me the best way

    WS.url("http://localhost:9001")
    .post(Json.toJson(ImmutableMap.of("param1", "foo", "param2", "bar")));
    

    Map from http://docs.guava-libraries.googlecode.com/git-history/release/javadoc/com/google/common/collect/ImmutableMap.html

    http://code.google.com/p/guava-libraries/wiki/ImmutableCollectionsExplained

提交回复
热议问题