A message body writer for Java class java.util.ArrayList…and MIME media type text/xml was not found

后端 未结 4 975
孤独总比滥情好
孤独总比滥情好 2020-11-28 11:11

Im using Jersey to build a REST Service and want to return a Collection as XML.

@GET
@Produces(MediaType.TEXT_XML)
@Path(\"/direct         


        
4条回答
  •  猫巷女王i
    2020-11-28 11:42

    Use

    List list = new ArrayList();
    GenericEntity> entity = new GenericEntity>(list) {};
    Response response = Response.ok(entity).build();
    

    The Generic entity wrapper works to get the output when using the Response builder.

    Reference

提交回复
热议问题