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 -

django - CSRF verification failed. Request aborted. CSRF cookie not set -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -