title: Spring request params to accept only Integers
body: <p>I am working on an spring restful endpoint which accepts page range(start &amp; end page number). I want my request params- pageStart and pageEnd to accept only integers. When I pass 'pageStart = a' through postman I get below error:</p>
  
  <pre><code>    @RequestMapping(value = "/{accNumber}/abc/xyz", method = RequestMethod.GET)
      @Loggable
      @ResponseBody
      public RestResponse&lt;Class1&gt; getData(
          @Loggable @PathVariable(value = "accNumber") String accNumber,
          @RequestParam(value = "pageStart", required = false, defaultValue = "0") Integer pageStart,
          @RequestParam(value = "pageEnd", required = false, defaultValue = "10") Integer pageEnd,
          HttpServletResponse response) throws Exception {
  
      Class1 class1 = new Class1();
      class1 = retrieveData(accNumber, pageStart, pageEnd);
      RestResponse&lt;Class1&gt; restResponse = new RestResponse&lt;Class1&gt;(
              class1);
  
      return restResponse;
      }
  </code></pre>
  
  <p>The request is not valid [Failed to convert value of type 'java.lang.String' to required type 'java.lang.Integer'; nested exception is java.lang.NumberFormatException: For input string: \"a\"]</p>
  
  <p>How do I handle this exception and let the user know that he should pass only integers?</p>