You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using Viewable in ExceptionMapper. I cannot specify the correct content-type as it always gets overridden by */*.
The ExceptionMapper
public Response toResponse(NotFoundException e) {
if (headers.getAcceptableMediaTypes().contains(MediaType.TEXT_HTML_TYPE)) {
return Response
.status(Response.Status.NOT_FOUND)
.type(MediaType.TEXT_HTML)
.entity(new Viewable("/errors/error_404.ftl", new HashMap<String, Object>()))
.build();
}
return Response.status(Response.Status.NOT_FOUND).entity("Not found").build();
}
I have dug into the source code and I found that content type defined on the resource is used and if not found, */* is default one. It completely ignores the type set on the Response object.
Link to the place, where */* is set:
I am using Viewable in ExceptionMapper. I cannot specify the correct content-type as it always gets overridden by
*/*
.The ExceptionMapper
I have dug into the source code and I found that content type defined on the resource is used and if not found,
*/*
is default one. It completely ignores the type set on the Response object.Link to the place, where
*/*
is set:jersey/ext/mvc/src/main/java/org/glassfish/jersey/server/mvc/internal/TemplateHelper.java
Line 108 in 7421515
The text was updated successfully, but these errors were encountered: