resteasy response

匿名 (未验证) 提交于 2019-12-03 02:38:01

问题:

I have a similar case as the one described here: Dynamically change RESTEasy service return type

The problem I'm facing is that I'm trying to return a list of objects (annotated with @XMLRootEntity), but I get a 500 server error code:

The server encountered an internal error (Could not find MessageBodyWriter for response object of type: java.util.ArrayList of media type: application/json) that prevented it from fulfilling this request.

Can you give some advice how to solve this issue?

I'm not sure exactly where to look.

Thanks.

回答1:

You should use interface instead of using implementation of list.

Try changing return type with : java.util.List

EDIT: Try to wrap list into GenericEntity :

List<String> myList = new ArrayList<String>(); // add ... final GenericEntity<List<String>> entity = new GenericEntity<List<String>>(myList) { }; Response.status(Status.BAD_REQUEST).entity(entity).build(); 


文章来源: resteasy response
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!