title: Spring 4 mvc global exception Handling
body: <p>I'm very new to spring mvc sorry if I'm asking a basic questions, I need to maintain Global Exception Handling in my spring 4 MVC, Jersey project and return JSON response to IOS mobile app. Now by using @ControllerAdvice and @ExceptionHandler, I have created a class like below </p>
  
  <pre><code>@ControllerAdvice
  public class GlobalExceptionHandlerController {
  
      @ExceptionHandler(Exception.class)
      public @ResponseBody handleException(HttpServletRequest reqException ex) {
              ErrorInfo response=new ErrorInfo();
                     if(ex.getMessage.contains("java.io")){
                       response.setMessage("FileNotFound exception occur");
                          return response;
                       }else if ...
      }
  </code></pre>
  
  <p>Please advice if above approach is correct or is there any alternative way to handle all exceptions occur in controller,service and DAO layer.</p>