Jersey: Consume all POST data into one object

会有一股神秘感。 提交于 2019-11-30 22:10:12

Got it. As per this document, I can use a MultivaluedMap<K,V> or Form to get all the POST data of the type application/x-www-form-urlencoded in one object. A working exmple:

    @POST
    @Path("/urienodedeample")
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    @Produces(MediaType.APPLICATION_JSON)
    public Response uriEncodedExample(MultivaluedMap<String,String> multivaluedMap) {
        logger.info(multivaluedMap);
        return Response.status(200).build();
    }

For cases where the Content-Type is multipart/form-data, this MultivaluedMap approach won't work.

Use FormDataMultiPart - docs here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!