Root element name in collections returned by RESTEasy

后端 未结 1 441
陌清茗
陌清茗 2021-01-11 10:08

I\'m using JAX-RS via RestEasy in JBoss AS 6. When my JAX-RS resource returns a collection of items (e.g. via a List), RESTEasy always uses the name collection

1条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-11 10:46

    Appeared to be a case of RTFM: RestEasy docs - Arrays and Collections of JAXB Objects

    So, if we wanted to output this XML

    
        bill
        monica
    
    

    We would use the @Wrapped annotation as follows:

    @GET
    @Path("list")
    @Produces("application/xml")
    @Wrapped(element="list", namespace="http://foo.org", prefix="foo")
    public List getCustomerSet() { ... }
    

    It's thus possible via the @Wrapped annotation. It's a RESTEasy specific one, but this will do for now.

    Leaving the question open in case someone has an even better solution (still looking for a global interceptor orso that lets RESTEasy do what Jersey does).

    0 讨论(0)
提交回复
热议问题