Enabling validation on the controller method

It's very simple to enable validation on the controller method. The following snippet shows an example of this:

    @RequestMapping(method = RequestMethod.POST, path = "/users/{name}/todos")
ResponseEntity<?> add(@PathVariable String name
@Valid @RequestBody Todo todo) {

The @Valid(package javax.validation) annotation is used to mark a parameter for validation. Any validation that is defined in the Todo bean is executed before the add method is executed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset