title: Spring Boot set content type and charset using HTTPHeaders for XML
body: <p>I am using the <code>HttpHeaders</code> in Spring Boot to set the content type and charset for a JSON response using:</p>
  
  <pre><code>HttpHeaders headers = new HttpHeaders();
  headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
  </code></pre>
  
  <p>Which then returns the header: <code>Content-Type →application/json;charset=UTF-8</code></p>
  
  <p>But the closet I can get with XML is <code>headers.setContentType(MediaType.APPLICATION_XML);</code></p>
  
  <p>Which gives me the header: <code>Content-Type →application/xml</code></p>
  
  <p>How can I go about including the charset in the content type for XML?</p>