1. Which HTTP header value tells Spring MVC that the request body contains XML?
Why: The Content-Type header tells the server the format of the request body. For XML, the value is application/xml.
2. Which Spring MVC strategy interface converts HTTP request and response bodies to Java objects and back?
Why:HttpMessageConverter reads the HTTP body into a Java object and writes a Java object into the HTTP body.
3. Is XML message conversion available in Spring MVC without any extra library?
Why: XML support is conditional. Spring MVC registers an XML converter only when a suitable library is available on the classpath.
4. Which annotation on a handler method parameter converts the HTTP request body into a Java object?
Why:@RequestBody tells Spring MVC to read the request body and convert it to the parameter type using an HttpMessageConverter.
5. Which annotation tells Spring MVC to write the return value of a handler method directly to the HTTP response body?
Why:@ResponseBody makes Spring MVC convert the returned object with an HttpMessageConverter and write it to the response body instead of resolving a view.
6. Which library must be added to the classpath so that Spring can convert XML using Jackson?
Why: Spring registers the Jackson XML converter automatically only when jackson-dataformat-xml is on the classpath.
7. After the Jackson XML library is added to the classpath, what extra Spring configuration is needed to register the XML converter?
Why: Spring detects the library on the classpath and registers the XML converter automatically. You can then use @RequestBody and @ResponseBody directly.
8. In Spring 7.0, which converter replaces the deprecated MappingJackson2XmlHttpMessageConverter?
Why:JacksonXmlHttpMessageConverter is the modern Jackson-based XML converter in Spring 7.0.
9. Why must JAXB be added as an external dependency in newer Java versions?
Why: JAXB used to be bundled with the JDK. It was deprecated in Java 9 and removed in Java 11, so it must now be added as a separate dependency.
10. Which converter is recommended when you already use the Marshaller and Unmarshaller abstractions from spring-oxm?
Why:MarshallingHttpMessageConverter works with Spring's Marshaller and Unmarshaller abstractions.
11. Which @RequestMapping attribute limits a handler method to requests that have an XML request body?
Why: The consumes attribute matches the Content-Type of the request. Use MediaType.APPLICATION_XML_VALUE to accept XML.
12. Which @RequestMapping attribute makes a handler method return XML to clients that ask for XML?
Why: The produces attribute defines the media type of the response. It is matched against the Accept header of the request.
13. Why is a list of objects often wrapped inside a separate class before it is returned as XML?
Why: A wrapper class lets the converter handle the generic collection type properly and gives the XML a clear root element.
14. Which Jackson XML annotation can set the name of the root XML element for a Java class?
Why:@JacksonXmlRootElement sets the name of the root XML element. Without it, the simple name of the class is used.
15. If JAXB is used for XML conversion, what kind of annotations are used on the Java classes?
Why: When JAXB is used for the conversion, the Java classes use JAXB binding annotations, such as @XmlRootElement, to describe the XML structure.