I am using Spring 4.1.4
and implementing a simple REST
service. I do have a POST
method which gets a Person
object as request.
@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
}
Bean:
public class Person {
public Person(){ }
private String firstname;
private String lastname;
private Integer activeState;
//getter+setter
}
My question is - is there a possibility to set a default value for the properties in the bean. Something like this:
@Value(default=7)
private Integer activeState;
I know when using the @RequestParam
annotation in a @RestController
methode it is possible to set a default value with @RequestParam(value="activeState", required=false, defaultValue="2")
but is there a possibility to do a similar thing on class level?