on-internet
← Community

Validation not working in Java Spring Application

Stack Overflow ·

I added the correct validation annotations to my DTO and API class, but when I input bad data thru postman, it doesn't error. API Class @RestController @RequestMapping("/laptops") @Validated public class LaptopApi { @Autowired private LaptopService laptopService; @Autowired private Environment environment; @GetMapping("/{id}") public ResponseEntity<LaptopDTO> getLaptop(@PathVariable Integer id) { LaptopDTO laptop = laptopService.getLaptop(id); return new ResponseEntity<>(laptop, HttpStatus.OK); } @GetMapping("/") public ResponseEntity<List<LaptopDTO>> getLaptops() { List<LaptopDTO> laptops = l

Comments

Sign in or sign up to comment and upvote.

No comments yet.