SPRING MVC / NOTES</>↗Spring MVC03 Jul 2026
In Spring MVC, handle exceptions globally by creating a class annotated with @ControllerAdvice or @RestControllerAdvice and adding methods annotated with @ExceptionHandler. For REST APIs, prefer @RestControllerAdvice, because it combines @ControllerAdvice and @ResponseBody, so returned objects are serialized as JSON automatically. package com.example.demo.exception; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springfr...
SPRING MVC / NOTES</>↗Spring MVC03 Jul 2026
In Spring MVC, the standard way to validate form data is to use Jakarta Bean Validation annotations on a form/DTO object, then check validation results in your controller with BindingResult. Since your project uses Jakarta EE, use jakarta.validation.* imports. 1. Add validation annotations to your form object Example form/DTO: import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Size; […]
SPRING MVC / NOTES</>↗Spring MVC03 Jul 2026
In Spring MVC or Spring Boot, you handle HTTP requests by creating controller classes. A controller receives a request, runs application logic, and returns either: a view name for server-rendered pages, or data such as JSON for REST APIs. 1. Basic Spring MVC Controller Use @Controller when you want to return views such as JSP, […]
SPRING MVC / NOTES</>↗Spring MVC03 Jul 2026
Building a Web Application Using Spring MVC A Spring MVC web application is typically built around these pieces: DispatcherServlet — the front controller that receives HTTP requests. Spring MVC configuration — enables MVC and configures controllers, view resolution, static resources, etc. Controllers — handle web requests. Services — contain business logic. Repositories — handle persistence, […]
KOTLIN / NOTES</>↗Kotlin03 Jul 2026
Kotlin coroutine lifecycle: the mental model A Kotlin coroutine is a lightweight concurrent task that runs inside a CoroutineScope and is controlled by a Job. The lifecycle is mostly about the state of that Job. At a high level: New → Active → Completing → Completed ↘ Cancelling → Cancelled Most of the time, you […]
KOTLIN / NOTES</>↗Kotlin03 Jul 2026
In Kotlin, you cancel a coroutine safely by calling cancel() on its Job or scope, and making sure the coroutine code is cooperative: it should suspend regularly or check for cancellation. Basic example import kotlinx.coroutines.* fun main() = runBlocking { val job = launch { try { repeat(1_000) { i -> println("Working $i") delay(500) // […]