What is the purpose of the @RequestBody annotation in Spring Boot?
In Spring Boot, @RequestBody turns a JSON or XML request body into a Java object. See auto-configuration, validation with @Valid and common errors.
2,886 posts about Java: questions with answers, tutorials and articles, newest first.
In Spring Boot, @RequestBody turns a JSON or XML request body into a Java object. See auto-configuration, validation with @Valid and common errors.
Publish events with ApplicationEventPublisher and handle them with @EventListener, including async and transaction-aware listeners.
Configure multipart size limits in Spring Boot, handle MaxUploadSizeExceededException globally and avoid the proxy and Tomcat pitfalls.
Replace the default thread-per-task executor with a ThreadPoolTaskExecutor and use it from @Async. Covers sizing, queue behaviour and rejection policies.
MultipartFile is Spring's abstraction for an uploaded file in a multipart request. Learn its methods, safe saving, size limits and upload security.
@Async runs Spring bean methods on a separate thread. Learn to enable it, return CompletableFuture, configure executors and avoid proxy and thread pitfalls.
Build secure file upload and download endpoints in Spring Boot using MultipartFile, a storage service that blocks path traversal and streamed responses.
Learn how Spring MVC frees the servlet thread with Callable, DeferredResult and CompletableFuture, and how to configure executors, timeouts and error handling.
Learn how Pageable (the request) and Page (the response) work together in Spring Boot, including Slice, DTO mapping and stable JSON serialization.
Learn how @SessionAttributes stores Spring MVC model attributes in the session, with a multi-step form example, SessionStatus cleanup and pitfalls.
Compare HttpSession, @SessionAttributes and @SessionAttribute in Spring MVC, with examples for multi-step forms, clearing state and session-scoped beans.
Use Pageable and Spring Data repositories to return pages, set sane size limits, sort safely and pick between Page, Slice and keyset scrolling.
Build a rate-limiting servlet filter in Spring with a fixed window and Bucket4j token buckets, returning 429 with Retry-After.
@RequestParam binds query and form parameters to controller method arguments. Learn required, defaultValue, Optional, lists and validation.
Cache-Control tells browsers and CDNs whether and how long to cache a response. Learn the key directives and the right policy for assets, HTML and APIs.
Combine Spring's cache abstraction with HTTP caching headers to cut database load and response time in a REST API, and learn how to evict stale entries safely.
@ResponseBody writes a controller's return value straight to the HTTP response, usually as JSON. See how it differs from views and @RestController.
Use ResponseEntity for one endpoint, a OncePerRequestFilter for every response, and ResponseBodyAdvice when the header depends on the returned body.
Content-Disposition controls inline display versus file download and the suggested file name. Learn syntax, Spring and Servlet examples and security tips.
Serve downloadable files in Spring MVC using ResponseEntity, Resource and HttpServletResponse, with correct headers and path traversal protection.