1. What is the main purpose of the @RequestHeader annotation in Spring MVC?
Why:@RequestHeader is used to bind HTTP request header attributes to controller method parameters.
2. Which element of @RequestHeader is used to specify the name of the HTTP header to bind?
Why: The value element (and its alias name) specifies the HTTP request header name.
3. What is the default value of the required element in @RequestHeader?
Why: The required element defaults to true, meaning the header must be present in the request.
4. If a required request header is missing and required is left at its default, what HTTP status code is returned?
Why: When a required header is missing, Spring MVC returns a 400 (Bad Request) status code.
5. What does setting required = false on @RequestHeader do?
Why: With required = false, the handler will still be invoked and the parameter will be null if the header is not present.
6. What is the effect of specifying a defaultValue in @RequestHeader?
Why:defaultValue supplies a fallback value and implicitly makes the header non-required.
7. When can the value element of @RequestHeader be omitted?
Why: The value element can be skipped if the parameter name matches the header name, provided debugging information is available.
8. Which parameter type can be used with @RequestHeader to receive all request headers as a map?
Why: Using a Map parameter with @RequestHeader binds all request headers into the map.
9. Which Spring-specific type can be used with @RequestHeader to access all headers and convenience methods like getContentType()?
Why:HttpHeaders is a Spring type that implements MultiValueMap and provides convenience methods for header access.
10. Can a single controller method have multiple @RequestHeader annotations?
Why: A method can declare multiple @RequestHeader parameters to bind several headers at once.
11. What happens if two handler methods have the same URI mapping but rely on different @RequestHeader parameters without specifying headers in @RequestMapping?
Why: Different @RequestHeader parameters alone do not create distinct mappings, leading to an ambiguous mapping exception.
12. How can ambiguity between handler methods that differ only by request headers be resolved?
Why: Adding the headers condition in @RequestMapping distinguishes the mappings.
13. If the target method parameter is not String, what does Spring MVC do with the header value?
Why: Spring MVC automatically converts header values to simple types such as int, long, and Date.
14. Which annotation is used to read a request header named User-Agent into a method parameter?
public String handle(@_____("User-Agent") String userAgent) { ... }
Why:@RequestHeader is the correct annotation to bind an HTTP request header to a method parameter.
15. Which annotation element should be used to make a request header optional?