如何在泽西设置默认为json而不是xml? [英] How to set to default to json instead of xml in jersey?
本文介绍了如何在泽西设置默认为json而不是xml?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用jersey jersey.java.net如果URI中没有接受标头或.xml后缀,如何将JSON设置为默认序列化而不是XML?
Using jersey jersey.java.net How do I set JSON as the default serialization instead of XML when there is no accept header or .xml suffix is in the URI?
推荐答案
您可以在@Produces注释中为每种媒体类型指定质量索引。如果允许XML和JSON,我可以执行以下操作使Jersey更喜欢JSON:
You can assign the quality index to each media type in @Produces annotation. I.e.you can do the following to make Jersey prefer JSON if both XML and JSON are allowed:
@Produces({"application/json;qs=1", "application/xml;qs=.5"})
这篇关于如何在泽西设置默认为json而不是xml?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文