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

后端 未结 7 1747
慢半拍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:37

    WS.url(url)
    .setContentType("application/x-www-form-urlencoded")
    .post("param1=foo¶m2=bar");
    

    This method uses an HTTP POST method to send its form request. As seen from the official documentation of Play, you should had already known of the GET method.

    这种方式是使用post方式提交表单请求,见于play的官方文档,get方式的你应该已经知道了。

提交回复
热议问题