Using the Jersey client to do a POST operation

前端 未结 6 1588
暖寄归人
暖寄归人 2020-12-02 12:20

In a Java method, I\'d like to use a Jersey client object to do a POST operation on a RESTful web service (also written using Jersey) but am not sure how to use the client t

6条回答
  •  抹茶落季
    2020-12-02 12:30

    Not done this yet myself, but a quick bit of Google-Fu reveals a tech tip on blogs.oracle.com with examples of exactly what you ask for.

    Example taken from the blog post:

    MultivaluedMap formData = new MultivaluedMapImpl();
    formData.add("name1", "val1");
    formData.add("name2", "val2");
    ClientResponse response = webResource
        .type(MediaType.APPLICATION_FORM_URLENCODED_TYPE)
        .post(ClientResponse.class, formData);
    

    That any help?

提交回复
热议问题