title: Send byte[] of image from Spring Controller to jQuery
body: <p>Tell me please right way how I can get image from Spring Controller and show its image on html? Now I'm trying like:</p>
  
  <pre><code>@RequestMapping(value = "dictionaries/getImage", method = RequestMethod.GET, produces = MediaType.ALL_VALUE)
  @ResponseBody
  public byte[] getImage(@RequestParam Long ticketTemplateId, @RequestParam String imageName) throws IOException{
      Long eventOrganizerId = eventOrganizerService.getCurrentUserOrganizerProfile().getId();
      byte[] result = fileStorageService.getImage(ticketTemplateId, eventOrganizerId, imageName);
  
      return result;
  }
  </code></pre>
  
  <p>jQuery code: </p>
  
  <pre><code>function downloadImage() {
              var imageName = $('#slc option:selected').val();
              var ticketTemplateId = getParameterByName('id');
              $.ajax({
                  url: 'getImage',
                  type: 'GET',
                  data: ({ticketTemplateId: ticketTemplateId, imageName: imageName}),
                  success: function(data) {
                      document.getElementById("ItemPreview").src = "data:image/png;base64," + data;
                  }
              })
          }
  </code></pre>
  
  <p>In browser console I get this error: </p>
  
  <pre><code> data:image/png;base64,%EF%BF%BDPNG%1A%00%00%00IHDR%00%00%00%EF%BF%BD%00%00%…%EF%BF%BD5%EF%BF%BD0%EF%BF%BD%EF%BF%BD%00%00%00%00IEND%EF%BF%BDB`%EF%BF%BD net::ERR_INVALID_URL
  </code></pre>