How ExceptionHandler return JSON in spring MVC
I am working on one project where client/server response is in JSON format. It is easy to send object in JSON format but what if some exception occured and you want to send the Exception also in JSON format ? After n number of trial. I finally able to do the above task . Step 1 : Add following annotation " AnnotationMethodHandlerExceptionResolver " in your <CONTROLLER>-servlet.xml file. <!-- JSON format support for Exception --> <bean id="methodHandlerExceptionResolver" class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver"> <property name="messageConverters"> <list> <ref bean="jacksonMessageConverter" /> </list> ...