Skip to content

Instantly share code, notes, and snippets.

@j-tim
Created May 17, 2020 20:26
Show Gist options
  • Save j-tim/473d55e5f2a677f18608d18c650586c7 to your computer and use it in GitHub Desktop.
Save j-tim/473d55e5f2a677f18608d18c650586c7 to your computer and use it in GitHub Desktop.
Spring MVC Restcontroller - Validation
package com.example.validation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
@Slf4j
@RestController
public class CustomerController {
@PostMapping
public void createCustomer(@Valid @RequestBody Customer customer) {
log.info("Valid customer: {}", customer);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment