动态改变RestEasy的服务回报型 [英] Dynamically change RESTEasy service return type
本文介绍了动态改变RestEasy的服务回报型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是否能够改变@Produces标注参数的值在我RestEasy的服务?结果
我给出的任务是多种格式报表集成到现有的报告系统。
因此,动态改变@Produces注解参数将帮助我很多东西。结果
在此先感谢!
Am I able to change the value of @Produces annotation parameter in my RESTEasy services??
The task I'm given is to integrate multiple format reporting to an existing reporting system.
So changing the @Produces annotation parameter dynamically would help me a lot.
Thanks in advance!
推荐答案
请你的方法返回一个响应
对象,并尝试这样的事情;
Make your method return a Response
object and try something like this;
int status = 200;
String type = MediaType.APPLICATION_XML;
String response = "<hello>world</hello>";
return Response.status(status).type(type).entity(response).build();
我觉得在响应类型将覆盖你注明什么,但我没有测试过。
I think the type in the response will override what you annotated, but I haven't tested it.
这篇关于动态改变RestEasy的服务回报型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文