And*_*rew 4 java annotations resteasy
我可以在RESTEasy服务中更改@Produces注释参数的值吗?
我给出的任务是将多种格式报告集成到现有的报告系统中.因此,动态更改@Produces注释参数将对我有所帮助.
提前致谢!
让你的方法返回一个Response
对象并尝试这样的事情;
int status = 200;
String type = MediaType.APPLICATION_XML;
String response = "<hello>world</hello>";
return Response.status(status).type(type).entity(response).build();
Run Code Online (Sandbox Code Playgroud)
我认为响应中的类型将覆盖您注释的内容,但我还没有对其进行测试.