What is the purpose of the BindingResult interface in Spring?
BindingResult collects binding and validation errors for a Spring MVC object. Declare it right after the @Valid parameter and check hasErrors() to handle failures.
2,886 posts about Java: questions with answers, tutorials and articles, newest first.
BindingResult collects binding and validation errors for a Spring MVC object. Declare it right after the @Valid parameter and check hasErrors() to handle failures.
Define a @Constraint annotation, write a ConstraintValidator and trigger it with @Valid to validate input in Spring MVC and Spring Boot.
@Valid triggers Bean Validation on controller parameters and nested objects. See setup, DTO examples, error handling and the @Validated difference.
Use @Valid with BindingResult, Jakarta constraint annotations and custom validators to check form and REST input in Spring MVC controllers.
Use Pageable for sorting and paging, query parameters for filters and JpaSpecificationExecutor to combine them into one safe, efficient database query.
@RequestBody tells Spring MVC to convert the HTTP request body into a Java object. See JSON binding, validation, error handling and common mistakes.
Compare URI, header, query parameter and media type versioning in Spring Boot, with code for each, native Spring 7 versioning and a deprecation plan.
Compare URI, header, parameter and media type versioning in Spring, see working controller code, and learn what built-in API versioning in Spring Framework 7 adds.
@RestController marks a Spring controller whose methods write return values to the response body. See a complete REST controller with validation and error handling.
@PathVariable binds a placeholder in a Spring URL mapping to a controller method parameter. Learn naming, conversion, optional variables and common errors.
Protect REST endpoints in Spring Boot by validating bearer JWTs with the OAuth 2.0 resource server support in Spring Security, including scopes and roles.
Use @RestController and the HTTP method mappings to build a REST API in Spring MVC, with validation, content negotiation and central error handling.
HttpHeaders is Spring's typed class for reading and building HTTP headers. See how to use it with ResponseEntity, @RequestHeader and RestClient.
@ModelAttribute binds form and query parameters to an object and shares data with the view. Learn forms, validation and mass assignment safety.
Authenticate REST APIs in Spring Boot 3 with SecurityFilterChain, HTTP Basic or OAuth2 JWT resource server, with password hashing and method security.
Spring MVC maps query and form parameters onto objects with @ModelAttribute. See records, validation, nested binding, @RequestParam and safe binding.
ResponseErrorHandler defines how RestTemplate detects and handles HTTP errors. Learn the default behaviour, custom handlers and the RestClient equivalent.
@InitBinder lets a controller customise how request data is bound to objects. See date formats, validators, field whitelists and @ControllerAdvice.
Learn how RestTemplate reports 4xx, 5xx and I/O errors, how to catch them, write a custom ResponseErrorHandler and map failures to ProblemDetail responses.
Use WebClient for non-blocking HTTP calls in Spring Boot, or RestClient with virtual threads and CompletableFuture for blocking code. Includes timeouts, retries and parallel calls.