Spring MVC ExceptionHandler gets easier.

Spring MVC exception handling gets easier with @ControllerAdvice with the release of Spring 3.2.1.

You can annotate your class as shown below and add a method to handle exception

public class AppCoreController
public @ResponseBody RequestStatus handleException(Exception exception)
RequestStatus errorStatus = new RequestStatus();
return errorStatus;

Please note that RequestStatus is a custom controller and yeap we are returning an class / object type as oppose to just String data type. 

These add exception handling capabilities to all your existing controller. 


Popular posts from this blog

OpenCover code coverage for .Net Core

ionic2 cordova build android - Unable resolve gradle 2.2.3

Using Custom DLL with IronPython / Scripts