title: How to add encoding to xml in java
body: <p>This might be an repeat question, but now I have search all over the place and still not able to produce the output.</p>
  
  <p>Currently I am getting the xml output, however I am not able to produce the encoding information.</p>
  
  <p>I want this -> <code>&lt;?xml version=“1.0” encoding=“UTF-8”?&gt;</code> to be added in the 1st line of the xml output.</p>
  
  <pre><code>@RequestMapping(value = "/ergoproject",method = RequestMethod.GET, produces = MediaType.APPLICATION_XML_VALUE)
  </code></pre>
  
  <p>The above snippet is used for the xml output which is like this...</p>
  
  <pre><code>&lt;List xmlns=""&gt;
      &lt;item&gt;
      &lt;projectname&gt;Test1&lt;/projectname&gt;
      &lt;/item&gt;
      &lt;item&gt;
      &lt;projectname&gt;Test2&lt;/projectname&gt;
      &lt;/item&gt;
      &lt;item&gt;
      &lt;projectname&gt;TEST3&lt;/projectname&gt;
      &lt;/item&gt;
      &lt;item&gt;
      &lt;projectname&gt;Test4&lt;/projectname&gt;
      &lt;/item&gt;
      &lt;item&gt;
      &lt;projectname&gt;Test5&lt;/projectname&gt;
      &lt;/item&gt;
  &lt;/List&gt;
  </code></pre>