Is there a way to modify Jersey generated XML resp

2019-03-01 16:30发布

In JAXB, it's possible (using the marshaller object). I don't know how to do it using Jersey. I was wondering if there's a way I can somehow inject something like:

<?xml-stylesheet type="text/css" href="something.css"?>

in the generated xml response.

1条回答
你好瞎i
2楼-- · 2019-03-01 17:01

See XmlHeader annotation. Attach that to your resource method. For example like this:

@GET
@Produces("application/xml")
@XmlHeader("<?xml-stylesheet type=\"text/css\" href=\"something.css\"?>")
public JaxbBean getSomeXml() {
    ....
}
查看更多
登录 后发表回答