title: Spring 4 MVC - Rest service - use default values in beans
body: <p>I am using <code>Spring 4.1.4</code> and implementing a simple <code>REST</code> service. I do have a <code>POST</code> method which gets a <code>Person</code> object as request. </p>
  
  <pre><code>@ResponseStatus(value = HttpStatus.CREATED)
  @RequestMapping(value = "", method = RequestMethod.POST, headers = "Accept=application/json", consumes = "application/json")
  public void add(@Valid @RequestBody Person oPerson) throws Exception {
      //do the things
  }
  </code></pre>
  
  <p><strong>Bean:</strong></p>
  
  <pre><code>public class Person {
  
      public Person(){ }
  
      private String firstname;
  
      private String lastname;
  
      private Integer activeState;
  
      //getter+setter
  }
  </code></pre>
  
  <p>My question is - is there a possibility to set a default value for the properties in the bean. Something like this:</p>
  
  <pre><code>@Value(default=7)
  private Integer activeState;
  </code></pre>
  
  <p>I know when using the <code>@RequestParam</code> annotation in a <code>@RestController</code> methode it is possible to set a default value with <code>@RequestParam(value="activeState", required=false, defaultValue="2")</code> but is there a possibility to do a similar thing on class level?</p>