Request & Response Handling
@PathVariable, @RequestParam, @RequestBody, @RequestHeader, content negotiation, JSON serialization
1Which annotation allows extracting a value from an HTTP header in a Spring MVC controller?
Which annotation allows extracting a value from an HTTP header in a Spring MVC controller?
คำตอบ
@RequestHeader allows extracting values from HTTP headers of the incoming request. This annotation automatically binds the value of a specific header to a method parameter. It supports type conversions and can be made optional with required=false. Useful for extracting authentication tokens, tracking information or client preferences like Accept-Language.
2How to retrieve the value of a cookie named 'sessionId' in a controller method?
How to retrieve the value of a cookie named 'sessionId' in a controller method?
คำตอบ
@CookieValue allows extracting the value of a specific HTTP cookie and binding it to a method parameter. The annotation accepts the cookie name as a parameter and supports automatic type conversions. It can also be marked as optional with required=false. Commonly used for session identifiers, user preferences or analytics tracking tokens.
3Why is injecting HttpServletRequest directly into a controller method less optimal than using Spring MVC annotations?
Why is injecting HttpServletRequest directly into a controller method less optimal than using Spring MVC annotations?
คำตอบ
Spring MVC annotations like @RequestParam, @RequestHeader or @PathVariable offer typed and automatic data extraction, with conversion and validation handling. Using HttpServletRequest directly requires manual parsing, makes code less readable and testable. Annotations also promote immutability and API contract clarity.
Which interface allows intercepting HTTP requests before they reach the controller in Spring MVC?
How to register a custom interceptor in a Spring MVC application?
+17 คำถามสัมภาษณ์
หัวข้อสัมภาษณ์ Spring Boot อื่นๆ
Spring Core - IoC & DI
Spring Boot Auto-Configuration
Spring Boot Starters
Application Properties & YAML
Logging with SLF4J & Logback
Spring Boot DevTools
Spring MVC Basics
Spring REST Controllers
Exception Handling
Bean Validation
Spring Data JPA Basics
JPA Entities & Relationships
JPA Queries
Spring Data Repositories
Spring Security Basics
Spring Boot Actuator
Unit Testing with JUnit & Mockito
Spring Boot Testing
Profiles & Environment
RestTemplate & WebClient
Async & Scheduling
Caching with Spring
Spring WebFlux (Reactive)
Spring Transactions
Advanced Authentication & Authorization
JWT & Stateless Security
OAuth2 & Authorization Server
Spring Boot & Docker
Microservices with Spring
Spring Cloud Config
Performance Optimization
GraalVM Native Images
เชี่ยวชาญ Spring Boot สำหรับการสัมภาษณ์ครั้งถัดไป
เข้าถึงคำถามทั้งหมด flashcards แบบทดสอบเทคนิค แบบฝึกหัด code review และตัวจำลองสัมภาษณ์
เริ่มใช้ฟรี