Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

304
Vistas
How to use javascript (in Angular) to get bytes encoded by java.util.Base64?

Since the functions related to DispatcherServlet are implemented by another department of my company, I can only complete the specific business classes of the back-end and the front-end, so I cannot directly return byte[] to the front-end.

So I use

                    Base64.getUrlEncoder().encodeToString(bytes);
                    response.put("data", data);

to return a RESTful json response to my front-end.

But in Java encodeToString, BASE64 util converts the bytes to BASE64 bytes and then returns a String based on ISO_8859_1...

First, How can I convert the string to the ISO_8859_1 byte[]?

Second, How can I decode the byte[] encoded by BASE64?

in frontEnd,

        this.http.pdf(data).subscribe(
          resp => {
            const data = WhatShouldTheMethodBe(respo['data']); //What should the method be?
            let blob = new Blob([data], { type: 'application/pdf' });
            let url = window.URL.createObjectURL(blob);
            let pwa = window.open(url);
            if (!pwa || pwa.closed || typeof pwa.closed == 'undefined') {
              alert('Please disable your Pop-up blocker and try again.');
            }
          }
        );

Thanks a lot.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda