title: REST Handling a wrong Parameter and required parameter
body: <p>My requirement is to get the json response with customized error message when a required <code>@RequestParam</code> is not sent to the request handler or invalid parameter(required is int but user is passing string) is sent to the request handler.</p>
  
  <p>currently I am trying to use the <code>@Exceptionhandler</code> mechanism to handle these exceptions. But the respective exception handler methods not getting invoked.</p>
  
  <p>Please see the code snippet:</p>
  
  <pre><code>@Controller
  @RequestMapping("api/v1/getDetails")
  public class Abc {
  
  
  @RequestMapping
  @ResponseBody
  public Envelope&lt;Object&gt; retrieveTransactions(@RequestParam(required = false) Integer a,
          @RequestParam int b, @RequestParam(required = false) boolean c,
          HttpServletRequest req) {`
  //implementation goes here
  }
  
  @ExceptionHandler(MissingServletRequestParameterException.class)
  @ResponseBody
  public Envelope&lt;Object&gt; missingParameterExceptionHandler(Exception exception,
          HttpServletRequest request) {
      Envelope&lt;Object&gt; envelope = null;
     //error implementation
      return envelope;
  }
  
  @ExceptionHandler(TypeMismatchException.class)
  @ResponseBody
  public Envelope&lt;Object&gt; typeMismatchExpcetionHandler(Exception exception, HttpServletRequest request) {
      Envelope&lt;Object&gt; envelope = null;
     //error implementation
      return envelope;
  
  }
  </code></pre>
  
  <p>Do I need to configure anything extra for exception handler? can anyone tell me where I am doing the wrong.</p>