How can I set the charset with JAX-RS? I\'ve tried @Produces(\"text/html; charset=UTF-8\") but that was ignored and only text/html was send with th
@Produces(\"text/html; charset=UTF-8\")
text/html
First setup @Produces annotation on your resource class methods.
@Produces
Then in MessageBodyWriter of your returned type, you can do this in writeTo() method:
MessageBodyWriter
writeTo()
response.setContentType(mediaType.toString);
Remark: You can inject response in your writer by:
response
writer
@Context protected HttpServletResponse response;