title: In Spring, @RequestParameter annotation not accepting boolean for defaultValue argument, it only works with string URL request parameters
body: <p>This question is related to Spring MVC method I have defined below:</p>
  
  <p>The value for the writeToRead parameter should be true or false. I expect the enduser calling my service to append to the url: <code>localhost:8080/index/someendpoint/sometype</code> the following request parameter: <code>?writeToRead=true</code> otherwise it should default to false if user doesn't append the parameter to the end of the url string. The problem is, the <code>defaultValue=false</code> doesn't seem to be acceptable in the <code>@RequestParameter</code> annotation. It looks like it only accepts string types rather than the boolean type I'm using. I could make defaultValue="false" but really, that's not a boolean. It's a string. How should I approach this? I can't use string alternatives (like "Y" or "N") to solve this problem because of method overloaded definition conflicts. How can I do this with booleans?  Thank you in advance!</p>
  
  <pre><code>@RequestMapping(value="/index/{endpoint}/{type}", method=RequestMethod.POST, consumes=kCompressed, produces=kProducesType)
  @ResponseBody
  public String indexData(@PathVariable(value="endpoint") String endpoint, @PathVariable(value="type") String type, 
                          @RequestParam(value="writeToRead", defaultValue=false) boolean writeToRead,                 
                          @RequestBody byte[] body, HttpServletRequest request) throws Exception {
      logger.debug("In indexData for endpoint " + endpoint);
  
      String bodyStr = decompress(body);
      return indexController.indexData(endpoint, type, bodyStr, writeToRead, getSecurityContextProvider(request));
  }   
  </code></pre>