spring - @ResponseStatus and @ResponseBody not working with @ExceptionHandler -


i tried implement @controlleradvice globally handle general exceptions related web application. wanted send wrapped json response response status set accordingly. here code sample.

@controlleradvice public class globalerrorhandler {      @responsestatus(httpstatus.bad_request)     @exceptionhandler(exception.class)     @responsebody     public response handleallerrors() {         response wrapped = new response(httpservletresponse.sc_bad_request, "error");         wrapped.setmessage("could not retrieve data");         return wrapped;     } } 

response pojo used wrap response. problem is, despite @responsestatus annotation, response has status code 500 (internal server error) default error page showing stack trace. @responsebody seems not work. documentation states send json response on @exceptionhandler method. don't understand i'm doing wrong in here.

i'm using spring 3.2.8 release framework , gson used message conversion, if matters.

any gladly appreciated.

found issue. because getters , setters of response pojo not defined.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -