Bird
0
0

Why might Spring Boot ignore the Accept header and always return JSON even if the client requests XML?

hard📝 Conceptual Q10 of 15
Spring Boot - Request and Response Handling
Why might Spring Boot ignore the Accept header and always return JSON even if the client requests XML?
ANo XML message converter is configured in the application
BThe controller method uses consumes instead of produces
CThe Accept header is misspelled in the client request
DSpring Boot does not support XML responses by design
Step-by-Step Solution
Solution:
  1. Step 1: Understand role of message converters

    Spring Boot uses message converters to convert objects to requested formats like JSON or XML.
  2. Step 2: Identify missing XML converter effect

    If no XML converter is present, Spring Boot cannot produce XML and defaults to JSON.
  3. Final Answer:

    No XML message converter is configured in the application -> Option A
  4. Quick Check:

    Missing converter causes fallback to JSON [OK]
Quick Trick: Add XML converter to support XML responses [OK]
Common Mistakes:
  • Assuming Spring Boot lacks XML support
  • Confusing consumes with produces
  • Ignoring message converter configuration

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes