jackson - Set Jersey to Default to JSON -


i using jersey jackson. want default endpoints (defined or not) return json.

let's have /hello endpoint produces application/json on get. if call /hello post, returning xml.

how 1 configure default json instead of xml?

i think found answer this. have not tested yet, pretty sure work.

@provider public class commonexceptionmapper implements exceptionmapper<exception> {     @override     public response toresponse(exception exception) {         return response.status(statuscode).type(mediatype.application_json).entity(resterror).build();     } } 

i missing .type().


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

c# - How do I get the Nth largest element from a list with duplicates, using LINQ? -

jsp - "Sending a redirect is forbidden after the response has been committed" in sendRedirect -