title: Spring : How to return base64 image in @RestController
body: <p>I have base64 String and I want to print base64 image on img tag using Spring's restcontroller.</p>
  <p>I'm developing the front and the back separately.</p>
  <p>this is my restcontroller</p>
  <pre><code>@CrossOrigin(origins = &quot;*&quot;, maxAge = 3600)
  @RestController
  @Validated
  public class TestController {
  
      @RequestMapping(value = &quot;/image/test&quot;,  method = RequestMethod.GET, produces = MediaType.IMAGE_PNG_VALUE)
      public byte[] getImage() throws Exception {
  
          String base64 = &quot;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYIAAACzCAY....&quot;; //from DB
  
          byte[] decodeBase64 = Base64.decodeBase64(base64);
          
          return decodeBase64;
  
      }
  }
  </code></pre>
  <p>this is my html</p>
  <pre><code>&lt;html&gt;
   &lt;body&gt;
     &lt;img src=&quot;http://localhost:8080/myProject/image/test&quot;/&gt;
   &lt;body/&gt;
  &lt;/html&gt;
  </code></pre>
  <p>The image is not output. What's the problem?</p>