消息:找不到类型的响应对象的MessageBodyWriter:java.util.Array媒体类型列表:application/json
说明:服务器遇到内部错误(找不到类型的响应对象的MessageBodyWriter:媒体类型的java.util.ArrayList:application/json)阻止它完成此请求
@GET
@Path("/{userName}/questions")
//@Produces("application/json")
public Response getUserQuestions(@PathParam("userName") String userName){
UserDAO userDAO = new UserDAO();
List<Question> questions = userDAO.getUserQuestionsByUserName(userName);
GenericEntity<List<Question>> entity = new GenericEntity<List<Question>>(questions){};
return Response.status(200).entity(entity).type(MediaType.APPLICATION_JSON).build();
}
Run Code Online (Sandbox Code Playgroud)
我在classpath中有resteasy jackson提供程序.尝试将返回类型表单更改ArrayList为List,然后GenericEntity根据resteasy响应将其包装,但仍然遇到相同的问题.
在tomcat7上运行.
谢谢.
我可以在RESTEasy服务中更改@Produces注释参数的值吗?
我给出的任务是将多种格式报告集成到现有的报告系统中.因此,动态更改@Produces注释参数将对我有所帮助.
提前致谢!