Bird
0
0

How can you customize Spring Boot to prefer URL path extensions (like .json or .xml) for content negotiation instead of Accept headers?

hard📝 Application Q9 of 15
Spring Boot - Request and Response Handling
How can you customize Spring Boot to prefer URL path extensions (like .json or .xml) for content negotiation instead of Accept headers?
AConfigure ContentNegotiationConfigurer with favorPathExtension(true)
BSet produces attribute to false in @GetMapping
CAdd @PathVariable for file extension in controller method
DDisable content negotiation in application.properties
Step-by-Step Solution
Solution:
  1. Step 1: Understand content negotiation customization

    Spring Boot allows configuring how it detects requested format.
  2. Step 2: Use ContentNegotiationConfigurer to prefer path extensions

    Calling favorPathExtension(true) enables using URL suffixes like .json or .xml.
  3. Final Answer:

    Configure ContentNegotiationConfigurer with favorPathExtension(true) -> Option A
  4. Quick Check:

    favorPathExtension(true) enables path extension negotiation [OK]
Quick Trick: Use favorPathExtension(true) to prefer URL suffixes [OK]
Common Mistakes:
  • Trying to disable produces attribute
  • Manually parsing path variables for format
  • Disabling content negotiation entirely

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes